Click to See Complete Forum and Search --> : OdbcDataAdapter.Fill problem with null strings on NT


pkahal
February 14th, 2005, 05:39 PM
Hi

I am getting this error on an NT machine but not on Win 2000.
My machine configuration: NT SP6a, MDAC 2.5 SP3, Microsoft .NET Framework Version 1.1 Redistributable Package, IE 6.

When I try query (select * from tableName) from any table that has result rows with null parameters, I get an exception. The Exception message is quite meaningless and just says : NO DATA.

Seems an issue specific to NT. I replaced the data with whitespaces and it works good.

My code is below.

//private void accessDB(string myInsertQuery, string myConnection)
{
string myConnection = "some user, pwd etcXXXX";
string myInsertQuery = "select * from tableName";

OdbcConnection myConn = new OdbcConnection(myConnection);
OdbcCommand myOdbcCommand = new OdbcCommand(myInsertQuery);

try
{
myOdbcCommand.Connection = myConn;
myConn.Open();
OdbcDataAdapter da = new OdbcDataAdapter();
OdbcCommand cmd = ((OdbcConnection)myConn).CreateCommand();
cmd.CommandText = myInsertQuery;
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds); // here it throws an exception
}
catch(Exception Ex)
{
Console.WriteLine(Ex.Message);
}
finally
{
myOdbcCommand.Connection.Close();
}
}

Krzemo
February 20th, 2005, 08:25 AM
And I think that it is not related to NT version, only to ODBC and its configuration. Maybe somwhere U set (on NT4) to treat empty strings as null and on NT2k U have that option disabled.

That kind of error usually means that U use somwhere null in WHERE .... or U have other errors in select or some network errors...

Best regards,
Krzemo.

pkahal
March 9th, 2005, 11:11 PM
Issue was resolved by loading latest MDAC ver 2.8
Thanks!