[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.odbcnet

An unhandled exception of type 'Microsoft.Data.Odbc.OdbcException' occurred in m

Mark Richardson

1/23/2003 6:58:00 PM

Hello,

Every time I run this piece of code. I get the following
error
"An unhandled exception of
type 'Microsoft.Data.Odbc.OdbcException' occurred in
microsoft.data.odbc.dll"

I get this error on the DataConn.Open() line. Can anyone
help me.

Here is my Code Below

Dim DataReader As OdbcDataReader
Dim DataConn As OdbcConnection
Dim DataCmd As OdbcCommand
Dim DataAdapter As OdbcDataAdapter
Dim strConn As String
Dim strQuery As String

strConn = "DNS=EmployeeDB;database=Employee_Database.mdb;"
strQuery = "Select * From tblTest"

DataConn = New OdbcConnection(strConn)
DataCmd = New OdbcCommand(strQuery, DataConn)
DataConn.Open()
DataReader = DataCmd.ExecuteReader()

lblTest.Text = DataReader("Test")

DataReader.Close()
DataConn.Close()
1 Answer

(Hussein Abuthuraya(MSFT))

1/23/2003 9:55:00 PM

0

Mark,

Wrap the Con.Open line in a Try Catch block and catch the error and display its message. This should give more meaningfull error description.

One more thing is the connectionstring doesn't look correct. Just make sure that the DSN is a system DSN and it points to the MDB file then changes the connection string to
"DSN=EmployeeDB".

The other thing that I would like to mention is that if you are running this code from Web Application then you may be running into Permissions issue.

I hope this helps!


Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.co....