Link to home
Start Free TrialLog in
Avatar of j-w-thomas
j-w-thomas

asked on

Changing from ODBC connections to MySQL connector/NET

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
ASKER CERTIFIED SOLUTION
Avatar of mayankagarwal
mayankagarwal
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of j-w-thomas
j-w-thomas

ASKER

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)
This is my web.config. It works fine with ODBC

<appSettings>
            <add key="DSN2" value="Server=localhost;Database=mydb;UID=root;Password=123;" />
</appSettings>
This is to connect to a MySQL db just to confirm as well
no follow up from expert after first entry, but I still needed help