protected
voidmysqlcon()
{
//数据库连接字符串跟连接sqlserver没有区别
string
constr
=
"server=localhostuserid=rootpassword=rootdatabase=test"
//下面使用mysql
connector/net提供的专用对象
mysqlconnection
mycon
=
new
mysqlconnection(constr)
mycon.open()
mysqlcommandmycmd
=
new
mysqlcommand("select
*
from
users",
mycon)
mysqldatareader
myreader
=
mycmd.executereader()
while
(myreader.read())
{
if
(myreader.hasrows)
{
messagebox.show(myreader.getstring("email")
)
}
}
myreader.close()
mycon.close()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)