ADO/MySQL连接的最佳方式是什么 [英] What is the best way ADO/MySQL connection

查看:74
本文介绍了ADO/MySQL连接的最佳方式是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的情况.我正在建立一个可供许多不同客户使用的网站.每个客户都有自己的MySql数据库,该数据库将存储他们的信息.  他们的初始身份验证将使用ASP.net角色进行 和存储在SQL 2005服务器中的用户.一旦通过身份验证,该网站就会在其MySQL数据库中查找客户的连接字符串.我可以进行身份​​验证和连接字符串检索,但不确定如何 将连接字符串与ADO.net连接器配合使用,以使所有这些组合在一起.这是Godaddy网站上的一个示例,但是如何为用户插入从SQL 2005服务器检索到的连接字符串....

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) & "<br>"
oRS.movenext
wend
oRS.close
end if

Set oRs = nothing
Set oConn = nothing

Any suggestions would be appreciated. Thank you.

推荐答案

这是一个C#论坛,看起来像VB6代码.

This is a C# forum and this looks like VB6 code.

您打算为此任务使用哪种语言?

What language are you planning to use for this task?

 


这篇关于ADO/MySQL连接的最佳方式是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆