Introduction
This is a class library in VB.NET made for access on MySQL databases. You can use this library without creating functions for working on the databases.
For using this library, you must install :
and the
In this library, you have 3 classes:
ManipStringForMySQL
: This class modifies the string for the SGBD
MySQL_Requettes
: This class makes the request on the SGBD
MySQL_Utils
: This class makes tests on the data of the SGBD
An example of the function with a dataset holding the results of the query:
Public Shared Function MyODBCDataset(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
Dim MyConString As String = _
"DRIVER={MySQL ODBC 3.51 Driver};SERVER=" & Server _
& ";DATABASE=" & LaBase & ";UID=" & User _
& ";PASSWORD=" & Password & ";OPTION=3;"
Dim MyODBCConnexion 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)
MyODBCConnexion.Close()
Return ds
Catch MyOdbcException As OdbcException
HttpContext.Current.Response.Write(MyOdbcException.ToString)
Catch MyException As Exception
HttpContext.Current.Response.Write(MyException.ToString)
End Try
End Function
The call of this function may be like that:
Dim MonDatasetTemp As DataSet = MySQL_Requettes.MyODBCDataset(
SQL,
constantes.ODBCBase,
constantes.ODBCServer,
constantes.ODBCPwd,
constantes.ODBCUser,
"MonDataset")
Conclusion
This library is the first example I made for the MySQL use in my ASP.NET solutions. I hope it can be easy for use in your projects.
You can also see the French version of this article more directed for the creation and use of the class library :