Problem with an ODBCConnection when using it in a WebService.

  • Thread starter Jonathan Sauvé
  • Start date

J

Jonathan Sauvé

Hi all,

I am having a problem with the ODBCConnection class when trying to open
a connection to my Paradox table in my WebService. When using it in a
normal windows app, it goes perfectly, but when using it in a WebService
context, it gives me the error : [System.NullReferenceException] {"Object
reference not set to an instance of an object." }
System.NullReferenceException.

Here is the code:

OdbcConnection cnnHist = new
OdbcConnection("Dsn=MyDSN;pwd=ThePassword;Exclusive=False;");
try
{
string Name = WindowsIdentity.GetCurrent().Name;
cnnHist.Open();

if (cnnHist.State == ConnectionState.Open)
{
//Add validation of the first row Datetime.

OdbcCommand cmd = new OdbcCommand("Select * from \"History\" Where MasterK
= ? ", cnnHist);
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add("MasterK", OdbcType.Int);
cmd.Parameters["MasterK"].Value = piMasterKey;
OdbcDataAdapter da = new OdbcDataAdapter(cmd);
result = new DataSet();
da.Fill(result, "HistoricalDataByDay");
}
}
catch (Exception e)
{
throw e;
}
finally{cnnHist.Close();}

I assured myself that the current WindowsIdentity is the same (IE
impersonnate if necessary), so that is not the problem.

Any idea

Thanks

Jonathan
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top