Hi, This is my first script trying to connect to a SQL database..
The script is below, the problem I'm having is that the Response.write(ObjConnection.State) & Response.write(ObjConnection.Provider) do not provide me any information when run as an asp file..
Questions I have, does the code look correct.. Should this be saved as an asp page or htm.. Why can't I see if the connection has been established.. As I'm not getting any results back.. Thanks
<html>
<head>Users</head>
<body>
<%
'Opens Connection to the Data Source
Set ObjConnection = CreateObject("ADODB.Connection")
' String required to connect to the data source (intergrated or defined username and password)
Str = "Driver={SQL Server};Server=IBLONPSD32X633\OI_DEV3;Database=malign_prod;UID=x;PWD=x;"
'Opens Connections to above SQL Database
ObjConnection.Open Str
Response.Write(ObjConnection.State)
Response.Write(ObjConnection.Provider)
'Opens Connection to RecordSet
Set objRecordSet = CreateObject("ADODB.RecordSet")
'Run a SQL query against the opened RecordSet
objRecordSet.Open "select * from pluser", ObjConnection
%>
<table border="1" width="100%">
<%do until ObjRecordSet.EOF%>
<tr>
<%For Each x In ObjRecordSet.Fields%>
<td><%Response.write(x.value)%></td>
<%Next
ObjRecordSet.MoveNext%>
</tr>
<%Loop
ObjRecordSet.Close
ObjConnection.Close%>
</table>
</body>
</html>