<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<%
'Dim cnn
'Set cnn = Server.CreateObject("ADODB.Connection")
'cnn.open "PROVIDER=SQLOLEDB;DATA SOURCE=SHIVALISAANVI;UID=ituser;PWD=123456;DATABASE=AdventureWorks2008R2 "
%>
<%
'Dim conn
'Set conn = Server.CreateObject("ADODB.Connection")
'conn.Open "Provider=SQLOLEDB; Data Source = (SHIVALISAANVI); Initial Catalog = AdventureWorks2008R2; User Id = ituser; Password=123456"
'If conn.errors.count = 0 Then
' Response.Write "Connected OK"
'End If
%>
<%
'declare the variables
Dim Connection
Dim Recordset
Dim SQL
'declare the SQL statement that will query the database
SQL = "SELECT TOP 10 * FROM [AdventureWorks2008R2].[Person].[Person]"
'create an instance of the ADO connection and recordset objects
Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")
'open the connection to the database
Connection.Open "PROVIDER=SQLOLEDB;DATA SOURCE=SHIVALISAANVI;UID=ituser;PWD=123456;DATABASE=AdventureWorks2008R2 "
'Open the recordset object executing the SQL statement and return records
Recordset.Open SQL,Connection
'first of all determine whether there are any records
If Recordset.EOF Then
Response.Write("No records returned.")
Else
'if there are records then loop through the fields
Do While NOT Recordset.Eof
Response.write Recordset("FirstName") &" "
Response.write Recordset("MiddleName")&" "
Response.write Recordset("LastName")&" "
Response.write "<br>"
Recordset.MoveNext
Loop
End If
'close the connection and recordset objects to free up resources
Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=nothing
%>
</body>
</html>
No comments:
Post a Comment