我有這個mySQL代碼連接到我的服務器。它連接就好了:ASP.NET中的oRecordset mySQL
Dim MyConString As String = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"SERVER=example.com;" & _
"DATABASE=xxx;" & _
"UID=xxx;" & _
"PASSWORD=xxx;" & _
"OPTION=3;"
Dim conn As OdbcConnection = New OdbcConnection(MyConString)
conn.Open()
Dim MyCommand As New OdbcCommand
MyCommand.Connection = conn
MyCommand.CommandText = "select * from userinfo WHERE emailAddress = '" & theUN & "'""
MyCommand.ExecuteNonQuery()
conn.Close()
但是,我有一個使用「oRecordset」從MySQL服務器獲取數據的舊傳統的ASP頁面:
Set oConnection = Server.CreateObject("ADODB.Connection")
Set oRecordset = Server.CreateObject("ADODB.Recordset")
oConnection.Open "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=example.com; PORT=3306; DATABASE=xxx; USER=xxx; PASSWORD=xxx; OPTION=3;"
sqltemp = "select * from userinfo WHERE emailAddress = '" & theUN & "'"
oRecordset.Open sqltemp, oConnection,3,3
,我可以使用oRecordset如下:
if oRecordset.EOF then....
或
strValue = oRecordset("Table_Name").value
或
oRecordset("Table_Name").value = "New Value"
oRecordset.update
等等
但是,我用我的生命,我找不到任何.NET代碼類似於我的經典ASP頁的!!!!!
任何幫助將是巨大的! :O)
大衛
太棒了,HTH。我做了與你的例子有點不同,但它有幫助!謝謝您的幫助。 – StealthRT 2010-04-09 22:53:15
很高興爲你效勞...... Raja – Raja 2010-04-09 22:55:51
Ugg ..拉惹,你有什麼想法如何添加一個新的記錄? rst.addnew似乎不起作用? – StealthRT 2010-04-09 22:59:53