ado连接mysql状态的判断,什么是ADO / MySQL连接的最佳方式

博主寻求帮助解决如何在ASP.NET中使用已获取的用户角色和SQL2005中的连接字符串,通过ADO.NET连接到各客户自己的MySQL数据库。讨论了从Godaddy示例中迁移代码到C#或VB.NET,以及所需的最佳实践。
摘要由CSDN通过智能技术生成

Here is my situation.  I am building a website that many different customers will use.  Each customer will have his/her own MySql Database which will house their information.  Their initial authentication will take place using ASP.net roles

and users stored in a SQL 2005 server.  Once authenticated the website will look for the customers connection string to his/her MySQL database.  I have the authentication and connection string retrieval working but I am not sure how to

use the connection string with the ADO.net connector to make this all come together.  Here is an example from the godaddy website, but how can I insert the connection string I have retrieved from the SQL 2005 server for the user....

Dim oConn, oRs

Dim qry, connectstr

Dim db_name, db_username, db_userpassword

Dim db_server

db_server = "mysql.secureserver.net"

db_name = "your_dbusername"

db_username = "your_dbusername"

db_userpassword = "your_dbpassword"

fieldname = "your_field"

tablename = "your_table"

connectstr = "Driver={MySQL ODBC 3.51 Driver};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_username & ";PWD=" & db_userpassword

Set oConn = Server.CreateObject("ADODB.Connection")

oConn.Open connectstr

qry = "SELECT * FROM " & tablename

Set oRS = oConn.Execute(qry)

if not oRS.EOF then

while not oRS.EOF

response.write ucase(fieldname) & ": " & oRs.Fields(fieldname) & "
"

oRS.movenext

wend

oRS.close

end if

Set oRs = nothing

Set oConn = nothing

Any suggestions would be appreciated. Thank you.

解决方案This is a C# forum and this looks like VB6 code.

What language are you planning to use for this task?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值