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'm trying to connect to a hosted MySQL database from my Ruby script. require
I'm experimenting on this code that I got from the net (I'm trying to
I am trying to use sqlalchemy to connect with mysql database. I have set
I am trying to connect to a database using MySQL C++ Connector. I have
I have been trying to display image from database using php but i am
am trying to fetch some data from a form, but i cant for some
I have two servers (virtual machines - I can remotely connect to these) -
I'm new to OOP and i'm trying to get a grasp on it. What
My MySQL DB table holds a BLOB image with image_id as key. I am
I am learning PHP and SQL, and I'm trying to figure out how to

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.