下面有壹個叫做
aspnet_iisreg.exe的程序,在命令行運行
aspnet_iisreg -i
運行結束就可以了。在最開始遇到
system.data.ado 找不到的問題
那是因為ado是beta版本的名稱。現在叫做oledb
sqlstr = "SELECT * FROM Employees;"
' Create a connection to the data source.
MyConnection = New OleDbConnection("Provider=SQLOLEDB;" _
& "server=localhost;"Integrated Security=SSPI;" _
& "Initial Catalog=Northwind") ' Create a Command object with the SQL statement.
MyCommand = New OleDbDataAdapter(sqlstr, MyConnection) ' Fill a DataSet with data returned from the database.
MyDataset = New DataSet
MyCommand.Fill(MyDataset)
' Create a new DataTable object and assign to it
' the new table in the Tables collection.
MyTable = New DataTable
MyTable = MyDataset.Tables(0)
' Find how many rows are in the Rows collection
' of the new DataTable object.
numrows = MyTable.Rows.Count
If numrows = 0 then
Response.Write("<p>No records.</p>")
Else
Response.Write("<p>" & Cstr(numrows) & " records found.</p>")
For loop1 = 0 To numrows - 1
' Print the values of the two columns in the Columns
' collection for each row.
Response.Write(MyTable.Rows(loop1).Item("FirstName") _
& " " & MyTable.Rows(loop1).Item("LastName") & "<br>")
Next loop1
End If
Response.Write("<p>End of data.</p>")
End Sub
</Script>
</html>在數據庫查詢(甚至是多表聯接查詢)返回單個記錄集的情況下,可以通過與使用 ADO 記錄集的方式幾乎相同的方式使用單個 DataTable(在此示例中為 MyTable)。參考《NET FRAMEWORK SDK文擋》