[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Andrew Varabei

3/21/2005 7:30:00 PM

I'm trying to get list of tables for specific DSN.
Can anybody help me?

that's the actual code, that do not allows me to fetch data

HELP!

public NameValueCollection getTables(string cnnStr)
{
[..]
byte []filter=new byte[] {(byte)'T',(byte)'A',(byte)'B',(byte)'L',(byte)'E',0};


ret=libodbc.SQLTables(_hStmt,catalog,(short)catalog.Length,none,0,none,0,filter,(short)5);

if( (ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo)) System.Diagnostics.Debug.WriteLine("- error: "+this.strOdbcError(_hStmt,OdbcHandleType.Stmt));

fetchTables();

[..]
}

// and code that gives me NoData
int _currentRow=0;
public bool nextRow ()
{
OdbcReturn ret=libodbc.SQLFetch (_hStmt);
if (ret != OdbcReturn.Success)
_currentRow = -1;
else
_currentRow++;
System.Diagnostics.Debug.WriteLine("nextRow:"+strOdbcReturn(ret));
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// NoData
return (ret != OdbcReturn.Error);
}
string []_columns=new string[5];
internal int fetchTables()
{
StringBuilder buff;
int len=0;
OdbcReturn ret=OdbcReturn.Error;
while(nextRow())
{
for(short i=0;i<_columns.Length;i++)
{
buff=new StringBuilder(MAX_BUFFER_LENGTH);
ret=libodbc.SQLGetData (_hStmt,(ushort)(i+1), OdbcCType.Binary, buff, MAX_BUFFER_LENGTH, ref len);
if ( (ret != OdbcReturn.Success) && (ret != OdbcReturn.SuccessWithInfo))
{
System.Diagnostics.Debug.WriteLine("- error: "+strOdbcError(_hStmt,OdbcHandleType.Stmt));
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// [Microsoft][ODBC Driver Manager] Invalid cursor state


return -1;
}
}

if (ret == OdbcReturn.NoData)
return 0;


}
return 0;
}