[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.aspnet.webservices

Problem with an ODBCConnection when using it in a WebService.

Jonathan Sauvé

7/9/2003 8:13:00 PM

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