Connect to the MySql class library _ MySQL in VB.net

Source: Internet
Author: User
This is a class library written in VB.net to connect to MySql. You can use this class library to directly operate MySql databases.

Before using this class library, you must install

Odbc mysql 3.51: http://www.mysql.com/downloads/api-myodbc-3.51.html

Driver ODBC. NET: http://www.microsoft.com/downloads/details.aspx? FamilyId = 6CCD8427-1017-4F33-A062-D165078E32B1 & displaylang = en

There are three classes in this library:

ManipStringForMySQL: This class modifies the SGBD string

MySQL_Requettes: send a request

MySQL_Utils: test SGBD data

The following is an example of using this library to operate MySql.

// Perform DataSet operations

Public Shared Function mydbcdataset (ByVal ReqSQL As String ,_
ByVal LaBase As String, ByVal Server As String ,_
ByVal Password As String, ByVal User As String ,_
ByVal NomDataSet As String) As DataSet
'Xxion à un server MySQL
'Avec le Driver ODBC 3.51 avec requette qui renvoie un dataset
Dim MyConString As String = _
"DRIVER = {MySQL ODBC 3.51 Driver}; SERVER =" & Server _
& "; DATABASE =" & LaBase & "; UID =" & User _
& "; PASSWORD =" & Password & "; OPTION = 3 ;"

Dim mydbcconnexion As New OdbcConnection (MyConString)
Try
Dim ds As New DataSet ()
Dim cmd As OdbcDataAdapter = New
OdbcDataAdapter (ReqSQL, MyConString)
Dim MyCommand As New OdbcCommand ()
Dim MyDataReader As OdbcDataReader
Cmd. Fill (ds, NomDataSet)
Mydbcconnexion. Close ()
Return ds
Catch mydbcexception As OdbcException
'
HttpContext. Current. Response. Write (mydbcexception. ToString)
Catch MyException As Exception
'
HttpContext. Current. Response. Write (MyException. ToString)
End Try
End Function

// Call a function

Dim MonDatasetTemp As DataSet = mysql_requettes.mydbcdataset (
SQL,
Constantes. ODBCBase,
Constantes. ODBCServer,
Constantes. ODBCPwd,
Constantes. ODBCUser,
"MonDataset ")

The class library used by this program can be downloaded at the address below: http://www.codeproject.com/dotnet/MySQLConnexion/MySQLConnexion.zip

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.