• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

querying SQL in ASP?

Homerboy

Lifer
Cna somebody provide a simple connection string/query example to use in an .asp webpage that will display the results of the query?

I just need some "jumping off point" of how to get this started so I can start to play with a working example, and I'm struggling with that.

I THINK I have a working connection string in the following:

<%
dim con, Rs
set con=server.CreateObject("adodb.connection")
con.Open "Provider=sqloledb;SERVER=SQL;DATABASE=CLS;UID=<Uid>;PWD=<UidPass>;"


Sql = “SELECT FILENO FROM MASTER WHERE FORW_NO =’1234’”

Dim Adapter as SqlDataAdapter = New SqlDataAdapter(SQL,cn)

Rs = New DataSet
Adapter.fill(rs,”master”)
Cn.close()
%>


Any help would be appreciated.
Thanks in advance.
 
This part is ASP.Net not ASP

Code:
Dim Adapter as SqlDataAdapter = New SqlDataAdapter(SQL,cn)

Rs = New DataSet
Adapter.fill(rs,&#8221;master&#8221;)

Heres an ASP sample:

Code:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "Provider=sqloledb;Data Source=SQLSERVERNAME;Initial Catalog=DATABASENAME;User Id=myUsername;Password=myPassword;

set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Customers", conn

for each x in rs.fields
  response.write(x.name)
  response.write(" = ")
  response.write(x.value)
next
%>

Here's a nice tutorial on ADO

http://www.w3schools.com/ado/default.asp
 
Yeah I guess I was mixing and matching languages then. Thanks for explaining.

I tried the example you gave (and subsequently looked at the examples in the tutorial you linked) but I still get an error when going to my page:

Server Error

500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.


I obviously updated with the correct server/table/user/passwords.
 
Connection string should be:

conn.Open "Driver= {SQL Server Native Client 10.0};Server=SQL;Database=CLS;Uid=USERNAME;Pwd=PASSWORD"
 
Back
Top