Home >Backend Development >C#.Net Tutorial >Operating MySql database in .Net
This is a class library written in VB.net for connecting to MySql. You can use this class library to directly operate the MySql database.
Before using this class library, you must install
ODBC MYSQL 3.51 download address: http://www.mysql.com/downloads/api-myodbc-3.51.html
Driver ODBC.NET download address: http:// www.microsoft.com/downloads/details.aspx?familyid=6ccd8427-1017-4F33-A062-D165078E32B1&DisplayLang=en
There are three categories in this library:
ManiPStringFormys QL: This kind of modified SGBD string
mysql_requettes: Send request
MySQL_Utils: Test SGBD data
The following is an example of using this kind of library to operate MySql
//Operation on DataSet
Public Shared Function MyODBCDataset(ByVal ReqSQL As String, _
As String, _
ByVal Password As String, _
ByVal NomDataSet As String) As DataSet
' Connexion à un server MySQL using using using using ‐ ‐ ‐ ‐ ‐‐ ‐ ‐ ing As String = _
"DRIVER={MySQL ODBC 3.51 Driver};SERVER=" & Server _
3;"
Dim MyODBCConnexion As New OdbcConnection(MyConString)
Try
Dim cmd As OdbcDataAdapter = New
OdbcDataAdapter(ReqSQL, MyConString)
Dim MyCommand As New OdbcCommand()
Dim MyDataReader As OdbcDataReader
cmd.Fill(ds, NomDataSet)
use using using ds to use through using ’ s ‐ ‐ ‐‐‐‐ ‐ to rite(MyOdbcException.ToString)
Catch MyException As Exception
'
HttpContext.Current. Response.Write(MyException.ToString)
End Try
End Function
//Call to function
Dim MonDatasetTemp As DataSet = MySQL_Requettes.MyODBCDataset(
SQL,
constantes.ODBCB ase,
constantes.ODBCServer,
constantes.ODBCUser,
"MonDataset")
The above is the content of operating MySql database in .Net. For more related articles, please pay attention to the PHP Chinese website (www.php.cn)!