i got error "ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
my code is;
Protected
Sub Page_Load(ByVal sender
As Object,
ByVal e As System.EventArgs)
Handles Me.Load
Dim
ConnStr As
String = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=test; uid=root;pwd=password;Option=3"
Using con
As New OdbcConnection(ConnStr)Using cmd
As New OdbcCommand("SELECT * FROM person", con)
con.Open()
DataGrid1.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection Or CommandBehavior.SingleResult)
Generally, I think this is a driver issue. To troubleshoot, you can first
check if the DSN exists in ODBC data source, because the error message says
that the data source name was not found. If the exception was thrown on
"conn.Open();" line, and the DSN exist, please also try to check if the
ODBC driver for DB2 has been installed properly.
If both DSN exists and ODBC driver for DB2 has been installed, please check
the connection string. You can generate a connection string with a .udl
file. Here are the steps:
1. Create a text file on desktop and rename it to .udl.
2. Double click it to open the Data Link Properties dialog box.
3. Select provider and connection to connect to the ODBC data source. Click
Test Connection on the Connection tab to test.
4. Click OK button and open the .udl file in the Notepad to see the
connection string.
5. Use this connection string to open the OdbcConnection object.
Liz
*********************
Please 'Mark as Answer' if this post helped you
Marked as answer by sachin_07 on Jun 01, 2008 01:20 PM
Hi Sachin, the problem you have is a driver problem. Make sure that you installed the same version of mysql odbc since there are few other drivers aside from 3.51 version.
I hope you don't mind. I'd like to you to test this code below too.
let's say in your Form_Load event..
Dim con As OdbcConnection
Dim cmd As OdbcCommand
Dim rd As OdbcDataReader
con = New OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDataBase; User=Username;Password=Password;Option=3;")
cmd = New OdbcCommand("select blah blah your query here", con)
Try
rd = cmd.ExecuteReader()
While rd.Read()
Response.write(rd("field_name_here"))
End While
rd.Close()
con.close()
Catch ex As Exception
response.write(ex.message)
End try
Happy coding!
Cheers,
CLIPER
------------------------------------------------
Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own commonsense. ---Buddha (563BC-483BC)
I was getting the same error using asp.net 4.0 tying to access a MySql database on my local system. I found after reading a bit is that the driver was not registered in the local system. I was
trying to use a user DNS or DNS-less connection to no avail. The problem is if developing on your local system you will need to create an ODBC system DNS on your local system first. It will register throughout your system including IIS. With that use the new
system DNS connect and your database connected page should render after making changes to use that system DNS in your pages.
sachin_07
Member
197 Points
114 Posts
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver s...
May 30, 2008 06:18 AM|LINK
Hi,
i'am new in MySql.....
i got error "ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
my code is;
Protected
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadDim
ConnStr As String = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=test; uid=root;pwd=password;Option=3" Using con As New OdbcConnection(ConnStr)Using cmd As New OdbcCommand("SELECT * FROM person", con)con.Open()
DataGrid1.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection Or CommandBehavior.SingleResult)DataGrid1.DataBind()
End Using End UsingEnd
Subhelp me......
liz_needansw...
Member
366 Points
66 Posts
Re: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driv...
May 30, 2008 06:55 AM|LINK
Generally, I think this is a driver issue. To troubleshoot, you can first
check if the DSN exists in ODBC data source, because the error message says
that the data source name was not found. If the exception was thrown on
"conn.Open();" line, and the DSN exist, please also try to check if the
ODBC driver for DB2 has been installed properly.
If both DSN exists and ODBC driver for DB2 has been installed, please check
the connection string. You can generate a connection string with a .udl
file. Here are the steps:
1. Create a text file on desktop and rename it to .udl.
2. Double click it to open the Data Link Properties dialog box.
3. Select provider and connection to connect to the ODBC data source. Click
Test Connection on the Connection tab to test.
4. Click OK button and open the .udl file in the Notepad to see the
connection string.
5. Use this connection string to open the OdbcConnection object.
*********************
Please 'Mark as Answer' if this post helped you
sachin_07
Member
197 Points
114 Posts
Re: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driv...
May 30, 2008 07:13 AM|LINK
hey thx Liz,
1. well exception was thrown on "conn.Open();" line......
2. DSN exist & ODBC driver installed properly
3. i have created .udl file on desktop.
4. i have .sql file on desktop, please tell me how can i specify connection string or connect to ODBC data...
Thanks & Regards,
Sachin
CLIPER
Participant
1304 Points
379 Posts
Re: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driv...
May 30, 2008 11:31 AM|LINK
Hi Sachin, the problem you have is a driver problem. Make sure that you installed the same version of mysql odbc since there are few other drivers aside from 3.51 version.
I hope you don't mind. I'd like to you to test this code below too.
let's say in your Form_Load event..
Dim con As OdbcConnection Dim cmd As OdbcCommand Dim rd As OdbcDataReader con = New OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDataBase; User=Username;Password=Password;Option=3;") cmd = New OdbcCommand("select blah blah your query here", con) Try rd = cmd.ExecuteReader() While rd.Read() Response.write(rd("field_name_here")) End While rd.Close() con.close() Catch ex As Exception response.write(ex.message) End tryHappy coding!
Cheers,
CLIPER
Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own commonsense. ---Buddha (563BC-483BC)
xangth2008
Member
2 Points
1 Post
Re: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driv...
Aug 18, 2010 04:52 AM|LINK
I was getting the same error using asp.net 4.0 tying to access a MySql database on my local system. I found after reading a bit is that the driver was not registered in the local system. I was trying to use a user DNS or DNS-less connection to no avail. The problem is if developing on your local system you will need to create an ODBC system DNS on your local system first. It will register throughout your system including IIS. With that use the new system DNS connect and your database connected page should render after making changes to use that system DNS in your pages.
I hope this helps out