这是在vb.net中为连接mysql中编写的一个类库。你可以使用这个类库直接操作mysql数据库。
在使用这个类库之前,你必须安装
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
在这个库中有三个类:
manipstringformysql: 此类修改sgbd的字符串
mysql_requettes: 发送请求
mysql_utils : 对sgbd数据进行测试
下面是使用此类库操作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
//对函数的调用
dim mondatasettemp as dataset = mysql_requettes.myodbcdataset(
sql,
constantes.odbcbase,
constantes.odbcserver,
constantes.odbcpwd,
constantes.odbcuser,
"mondataset")
新闻热点
疑难解答
图片精选