views:

40

answers:

2

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")
%>
+1  A: 

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

Jeroen
+1  A: 

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.

OneSHOT