Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3237040
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:41:29+00:00 2026-05-17T17:41:29+00:00

I am trying connect to MySQL database from ASP.net code. some my connection is

  • 0

I am trying connect to MySQL database from ASP.net code. some my connection is not working.

for the below code I am getting invalied argument DRIVER. Can you help me to correct this.

Or show me some sample code.

Label1.Text = ""
        Label2.Text = ""
        Try
            Dim conStr As New SqlClient.SqlConnection
            conStr.ConnectionString = "DRIVER={MySQL ODBC 5.1 Driver};" +
                         "SERVER=localhost;" +
                         "DATABASE=aa;" +
                         "UID=aa;" +
                         "PASSWORD=aa;" +
                         "OPTION=3"

            Response.Write("Connection string:  " & conStr.ConnectionString)
            conStr.Open()
            If conStr.State = ConnectionState.Open Then
                Label1.Text = "SQLConnection conStr is Open"
                conStr.Close()
            ElseIf conStr.State = ConnectionState.Closed Then
                Label1.Text = "SQLConnection conStr is closed"
            End If
        Catch sqlxcp As SqlClient.SqlException
            Label2.Text = sqlxcp.ToString

        Finally
        End Try

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:41:30+00:00Added an answer on May 17, 2026 at 5:41 pm

    SqlClient is for SQL Server. With the connection string above you need to use the OBBC provider classes (from here):

    using Microsoft.Data.Odbc;
    
    namespace myodbc3
    {
      class mycon
      {
        static void Main(string[] args)
        {
          try
            {
              //Connection string for Connector/ODBC 3.51
              string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" +
                "SERVER=localhost;" +
                "DATABASE=test;" +
                "UID=venu;" +
                "PASSWORD=venu;" +
                "OPTION=3";
    
              // Connect to MySQL using Connector/ODBC
              OdbcConnection MyConnection = new OdbcConnection(MyConString);
              MyConnection.Open();
     ...
    

    Using the MySql.Data.MySqlClient.MySqlConnection class, MySQL connection should be of this form:

    Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
    

    (Default port is 3306)

    If you are using the MySQL Connector/ODBC 3.51 (which your code suggests):

    Driver={MySQL ODBC 3.51 Driver};
    Server=myServerAddress;Database=myDataBase;
    User=myUsername; Password=myPassword;Option=3;
    

    The ConnectionStrings site is a great resource.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to connect to mysql database from jsp page. The connection code
I'm trying to connect to a MySQL database using my ASP.NET Web Forms Application.
I'm trying to connect to the MySql database from a Java servlet. I'm working
I am trying to connect to a remote mysql database from an iPhone. I
I' trying to get some data from Oracle via ODBC to mySQL database. And
I am working with a MySQL Database and having some issues while trying to
I'm trying to connect to MySQL database from node.js using db-mysql library. Everything works
I am trying to connect to a local MySQL database from a VB6 application.
I'm trying to pull some html data from a mysql database to populate a
im getting this error while trying to connect a mysql database to an editor,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.