ODBC Connection failing in Web service

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

Hi there,

I have a class library that I am using to connect to an ODBC data
source. If I consume this class library within a standard windows forms app
the connection succeeds. If I consume it in an asp.net web service it
fails. Would this be down to the assembly being run with different
credentials? If so how would I resolve this?
 
Hi there,

I've moved the data source into the site root but still cannot gain
access to the database. I've tried giving *everyone* permissions to the
folder and database file but still no luck! I haven't tested on the actual
web server i'm going to be uploading too yet, maybe I should try that. Any
suggestions would be most helpful.

Nick.
 
Well the answer to that one was no. Am I missing something in whe .config
file? It's got all of it's default values in at the moment.

Nick.

Nick said:
Hi there,

I've moved the data source into the site root but still cannot gain
access to the database. I've tried giving *everyone* permissions to the
folder and database file but still no luck! I haven't tested on the
actual web server i'm going to be uploading too yet, maybe I should try
that. Any suggestions would be most helpful.

Nick.
 
¤ Hi there,
¤
¤ I have a class library that I am using to connect to an ODBC data
¤ source. If I consume this class library within a standard windows forms app
¤ the connection succeeds. If I consume it in an asp.net web service it
¤ fails. Would this be down to the assembly being run with different
¤ credentials? If so how would I resolve this?

Some additional information might help. What is error you are getting?

What kind of database are you using? What type of authentication is your web service configured for?


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Hi there,

Well it's hard to tell what error is occuring to be honest with you! I
don't even seem to be allowed to dump a text file into the root of the web
site. Or even in a folder with "Full Control" security priviledges for the
ASP accounts.

I just know that the error is occuring when attempting to open the
connection to the database.

-----------------

Private Function connectToDataSource() As Boolean
Dim pStrConnectionString As String = "dsn=" & FEEDBACKDATAODBCDSNNAME
Try
cODBConnection = New OdbcConnection(pStrConnectionString)
Call cODBConnection.Open()

Return (True)
Catch ex As Exception

Return (False)
End Try
End Function

-----------------

False is always returned when calling this function from a web service,
calling it from a Windows forms application works fine. This method is in a
class library. Authentication is currently set to "Windows" with anonymous
access disabled, although I've tried variations.

Nick.
 
Forgot to mention that it is an Access database.

Nick said:
Hi there,

Well it's hard to tell what error is occuring to be honest with you! I
don't even seem to be allowed to dump a text file into the root of the web
site. Or even in a folder with "Full Control" security priviledges for
the ASP accounts.

I just know that the error is occuring when attempting to open the
connection to the database.

-----------------

Private Function connectToDataSource() As Boolean
Dim pStrConnectionString As String = "dsn=" & FEEDBACKDATAODBCDSNNAME
Try
cODBConnection = New OdbcConnection(pStrConnectionString)
Call cODBConnection.Open()

Return (True)
Catch ex As Exception

Return (False)
End Try
End Function

-----------------

False is always returned when calling this function from a web service,
calling it from a Windows forms application works fine. This method is in
a class library. Authentication is currently set to "Windows" with
anonymous access disabled, although I've tried variations.

Nick.
 
I've just tried using the odbcconnection object too, I can get it working in
a Windows forms app, but not the web service again!
 
Well I've finally got my error message at last!

System.Data.Odbc.OdbcException: ERROR [IM002] [Microsoft][ODBC Driver
Manager] Data source name not found and no default driver specified at
System.Data.Odbc.OdbcConnection.Open()

So if it manages to find the data source in a Windows forms app how comes
it's failing now? Is this datasource only visible to certain users? Thanks
in advance for any help.

Nick.
 
Thanks Paul, I've ended up using a normal connection string. Everything
works hunky dory, *touch wood*.

Nick.
 
Back
Top