2010-01-19 64 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