2010-01-19 61 views
0

我想从我的mysql数据库表中检索列值(登录名,密码)到vbscript。我怎样才能做到这一点?我没有vbscript的经验,我必须这样做,作为我的项目的一部分。我成功地连接到Mysql数据库表,但我不知道如何在vbscript中检索这些列值(都在varchar中)。我在谷歌搜索了很多,但没有得到任何帮助。任何人都可以帮我吗?如何检索vbscript中的列值

+2

你能告诉你的代码成功地连接到MySQL? – AnthonyWJones 2010-01-19 14:03:43

回答

0

这是ASP中的一个例子,它应该让你去你需要去的地方。注意,这给你一个连接记录,这是去,因为它尽可能快地释放数据库连接返回到池中的首选方式:

<%@Language="VBScript"%> 
<!-- Include file for VBScript ADO Constants --> 
<!--#include File="adovbs.inc"--> 
<% 
    ' Connection string. 
    strCon = "Provider=sqloledb;Data Source=myServer;Initial Catalog=Northwind;User Id=myUser;Password=myPassword" 

    ' Create the required ADO objects. 
    Set conn = Server.CreateObject("ADODB.Connection") 
    Set rs = Server.CreateObject("ADODB.recordset") 

    ' Open the connection. 
    conn.Open strCon 

    ' Retrieve some records. 
    strSQL = "Select * from Shippers" 
    rs.CursorLocation = adUseClient 
    rs.Open strSQL, conn, adOpenStatic, adLockOptimistic 

    ' Disconnect the recordset. 
    Set rs.ActiveConnection = Nothing 

    ' Release the connection. 
    conn.Close 

    ' Check the status of the connection. 
    Response.Write("<BR> Connection.State = " & conn.State) 

    Set conn = Nothing 

    ' Use the diconnected recordset here. 
    Response.Write("Column1") 
    Response.Write("Column2") 

    ' Release the recordset. 
    rs.Close 
    Set rs = Nothing 
%> 

你可以得到full contents of adovbs.inc here