?
Solved

Changing from ODBC connections to MySQL connector/NET

Posted on 2011-03-15
6
Medium Priority
?
496 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
6 Comments
 
LVL 5

Accepted Solution

by:
mayankagarwal earned 400 total points
ID: 35145917
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
ID: 35146837
Thanks and how about a NonQuery ? Is it still:

objRdr = objCmd.ExecuteReader()
0
 
LVL 3

Author Comment

by:j-w-thomas
ID: 35146868
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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 3

Author Comment

by:j-w-thomas
ID: 35146876
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
ID: 35146913
This is to connect to a MySQL db just to confirm as well
0
 
LVL 3

Author Closing Comment

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

Featured Post

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this article, we’ll look at how to deploy ProxySQL.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

765 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