Read SQL Server DB using .ASP-VB
I am trying to connect an .ASP Page to a MS SQL Server Database to read data, code below, its not working any ideas with Code below
<%
Dim oConn, oRs
Dim qry, connectstr, fieldname, tablename
Dim db_name, db_username, db_userpassword
Dim db_server
db_server = "end-novsql1"
db_name = "StoreRepairs"
db_username = "StoreRepairUser"
db_userpassword = "5t0re5"
fieldname = "callid"
tablename = "dbo_Call"
connectstr = "Driver={SQL Server};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_username & ";PWD=" & db_userpassword
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr
qry = "SELECT * FROM " & tablename
Set oRS = oConn.Execute(qry)
%>
<table width = 600 border="1">
<tr>
<td width="300"><strong>CallID</strong></td>
</tr>
<% Set oRS = oConn.Execute(qry)
if not oRS.EOF then
while not oRS.EOF
%>
<tr>
<td width="200">
<%= oRs.Fields("CallID") %></td>
</tr>
<% oRS.close
end if
Set oRs = nothing
Set oConn = nothing
%>
|