how to use mysql with asp.net?

前端 未结 3 610
一个人的身影
一个人的身影 2021-01-14 07:12

I want to use MySQL with my Asp.Net application and would like to know how. I am going to use MySQL for the first time. The most important thing I would like to know is how

相关标签:
3条回答
  • 2021-01-14 08:07

    You can use the following connectionstring in your web.config to connect to mysql database:

    <connectionStrings>
      <add name="MySQLConnStr" connectionString="DRIVER={MySQL ODBC 3.51 Driver};Database=YourDatabase;Server=localhost;UID=YourUsername;PWD=YourPassword;"/>
    </connectionStrings>
    

    You need to do the following before attempting to connect from ASP.NET to MySQL database:

    1. Make sure you have installed the .Net Framework on your server
    2. Download the ODBC .Net data provider and install it on your development machine or your server. You can download it here: http://www.microsoft.com/downloads/details.aspx?FamilyID=6ccd8427-1017-4f33-a062-d165078e32b1&DisplayLang=en
    3. install MySQL ODBC Driver-MyODBC 3.51. You can download it here: http://dev.mysql.com/downloads/connector/odbc/3.51.html

    The following will perfectly explain to you the architecture of ODBC: ODBC

    And for more details go through following referenced articles:

    Connect to MySQL database from ASP.NET

    An ASP.NET Application Using a MySQL Database (Sample Application)

    ASP.NET with MySQL - Getting started

    Connector/NET Examples

    Hope this helps.

    0 讨论(0)
  • 2021-01-14 08:12

    You have to use MySql connector API to establish the connection, execute queries and retrieving results. Take a look at tutorials.

    0 讨论(0)
  • 2021-01-14 08:15

    try downloading this http://www.devart.com/dotconnect/mysql/ this is a great tool and easy to connect mysql to ASP.net but t his is trail version

    and then jst drop the components on the form/page

    sample code
    
     using Devart.Data.MySql; 
    
      MySqlConnection conOne = new MySqlConnection("user id=root;password=root;host=localhost;database=studentDB");
    string quePrvLT = "select rollna from studentTAble where rollna =" +res;
    MySqlCommand cmdPLT = new MySqlCommand(quePrvLT, con);
    int leaPLdB = (float)cmdPLT.ExecuteScalar();
    
    0 讨论(0)
提交回复
热议问题