我正在尝试连接到本地服务器上的数据库。该数据库名为“dbtest”。当然,我已经忘记了我的实际密码并将其替换为“密码”。
这是我在每个教程中看到的典型代码,但它根本不起作用。请帮忙。
<%
Dim con, rs
con = Server.CreateObject("ADODB.Connection") 'I think it is something to do with this line
con.Open "Provider=sqloledb;SERVER=localhost;DATABASE=dbtest;UID=administrator; PWD=password;"
rs = Server.CreateObject("ADODB.Recordset")
%>
答案 0 :(得分:1)
这不是asp.net。这是经典的ASP
您必须首先阅读有关创建数据库驱动的webapp的信息。 阅读有关SqlDataSource和GridView控件的信息。您不需要任何代码。
此处:http://www.asp.net/data-access/tutorials/querying-data-with-the-sqldatasource-control-cs
答案 1 :(得分:1)
您所关注的教程可能有些过时,.net包含更新的SQL数据访问类,请看这里
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.aspx
特别是在SqlConnection类和SqlCommand类中。
有一个有用的教程可以找到here。
ADODB.Recordset的等价物将是SqlDataReader类。