本篇文章为大家展示了VB.NET中怎么操作MySql数据库,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
VB.NET操作MySql的一个例子
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
'Connexion à 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 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
上述内容就是VB.NET中怎么操作MySql数据库,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注编程网行业资讯频道。