为什么我的 asp.net 会导致运行时错误?

发布于 2024-09-10 06:39:46 字数 411 浏览 2 评论 0原文

我正在尝试连接到本地服务器上的数据库。该数据库称为“dbtest”。当然,我已经放弃了我的实际密码,并将其替换为“password”。

这是我在每个教程中看到的典型代码,但它根本不起作用。请帮忙。

<%
    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")
%>

I am trying to connect to a database on my local server. The database is called "dbtest." Of course, I have left off my actual password and replaced it with "password."

This is the typical code I see on every tutorial, but it doesn't work at all. Please help.

<%
    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")
%>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小草泠泠 2024-09-17 06:39:46

这不是 ASP.NET。这是经典的 ASP

您必须首先阅读有关创建数据库驱动的 Web 应用程序的内容。
了解 SqlDataSource 和 GridView 控件。您不需要任何代码。

这里: http://www.asp.net/data-access/tutorials/querying-data-with-the-sqldatasource-control-cs" asp.net/data-access/tutorials/querying-data-with-the-sqldatasource-control-cs

This is not asp.net. This is classic ASP

You have to read about creating a database driven webapp first.
Read about SqlDataSource and GridView controls. You won't need any code.

here: http://www.asp.net/data-access/tutorials/querying-data-with-the-sqldatasource-control-cs

白首有我共你 2024-09-17 06:39:46

您正在学习的教程可能有点过时,.net 包含用于 SQL 数据访问的更新类,请查看此处

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.aspx

特别是在 SqlConnection 类和 SqlCommand 类中。

有一个有用的教程,可以在此处找到。

ADODB.Recordset 的等效项是 SqlDataReader 类。

The tutorials you are following may be a little out of date, .net includes updated classes for SQL data access, have a look here

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.aspx

Particularly at the SqlConnection class and SqlCommand class.

There is a useful tutorial that can be found here.

The equivalent of the ADODB.Recordset would be the SqlDataReader class.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文