Solved

Changing from ODBC connections to MySQL connector/NET

Posted on 2011-03-15
6
487 Views
Last Modified: 2012-05-11
Question: Currently I use the following items for db connections, but I have had to change to MySQL Connector/Net and of course i need the new versions of the following:

This is how I normally make the declarations:

Dim objConn As New OdbcConnection(ConfigurationSettings.AppSettings("DSN"))
Dim objCmd As OdbcCommand
Dim objRdr As OdbcDataReader
Dim objDA As OdbcDataAdapter
Dim objDS As New DataSet()

Are the new versions:

Dim objConn As New SqlConnection(ConfigurationSettings.AppSettings("DSN2"))  'defined in web.config
Dim objRdr As SqlDataReader
Dim objCmd As SqlCommand
Dim objDA As SqlDataReader

are these correct?

If I add parameters is it still

objCmd.Parameters.Add("test",strTest)

Thanks
0
Comment
Question by:j-w-thomas
  • 5
6 Comments
 
LVL 5

Accepted Solution

by:
mayankagarwal earned 100 total points
Comment Utility
yes it is correct.

If you are getting any error while using this code then please mention the same

Mayank
0
 
LVL 3

Assisted Solution

by:j-w-thomas
j-w-thomas earned 0 total points
Comment Utility
Thanks and how about a NonQuery ? Is it still:

objRdr = objCmd.ExecuteReader()
0
 
LVL 3

Author Comment

by:j-w-thomas
Comment Utility
I do not think that i have the connection string correct in my web.config. I am getting this error:

Message A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
0
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
LVL 3

Author Comment

by:j-w-thomas
Comment Utility
This is my web.config. It works fine with ODBC

<appSettings>
            <add key="DSN2" value="Server=localhost;Database=mydb;UID=root;Password=123;" />
</appSettings>
0
 
LVL 3

Author Comment

by:j-w-thomas
Comment Utility
This is to connect to a MySQL db just to confirm as well
0
 
LVL 3

Author Closing Comment

by:j-w-thomas
Comment Utility
no follow up from expert after first entry, but I still needed help
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Loading csv or delimited data files to MySQL database is a very common task frequently questioned about and almost every time LOAD DATA INFILE comes to the rescue. Here we will try to understand some of the very common scenarios for loading data …
A lot of articles have been written on splitting mysqldump and grabbing the required tables. A long while back, when Shlomi (http://code.openark.org/blog/mysql/on-restoring-a-single-table-from-mysqldump) had suggested a “sed” way, I actually shell …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now