我继承了一些代码,需要有关如何访问某些asp.net代码正在使用的数据库的帮助:
set oconn_mtk = server.createobject("ADODB.Connection")
oconn_mtk.CursorLocation = 3
oconn_mtk.mode = 3
oconn_mtk.Open "database_name"
这对任何人都有意义吗?我如何访问该数据库的数据?
非常感谢你的帮助!
答案 0 :(得分:1)
这似乎不是ASP.NEXT(新即将推出的.NET乐趣),而是看起来更像是经典的ASP。
SQL = "SELECT * FROM TABLE_NAME"
Set oconn_mtk = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open SQL,Connection
If rs.EOF Then
Response.Write("No records returned.")
Else
'if there are records then loop through the fields
Do While NOT rs.Eof
Response.write rs("FIRST_FIELD_NAME")
Response.write rs("SECOND_FIELD_NAME")
Response.write rs("THIRD_FIELD_NAME")
Response.write "<br>"
rs.MoveNext
Loop
End If
rs.close : oconn_mtk.close