S
small pig
Unregistered / Unconfirmed
GUEST, unregistred user!
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.ADO" %>
<%
'设置连接串...
Dim strConnString as String
strConnString = "Provider=SQLOLEDB;
Data Source=(local);
" &
_
"Initial Catalog=pubs;
User ID=sa"
'创建对象ADOConnection
Dim objConn as ADOConnection
objConn = New ADOConnection
'设置ADOCOnnection对象的连接串
objConn.ConnectionString = strConnString
objConn.Open() '打开数据链路
'创建SQL字符串
Dim strSQL as String = "SELECT * FROM authors"
'创建对象ADODatasetCommand 和Dataset
Dim objDSCommand as ADODatasetCommand
Dim objDataset as Dataset = New Dataset
objDSCommand = New ADODatasetCommand(strSQL, objConn)
'填充数据到Dataset
'并将数据集合命名为 "Author Information"
objDSCommand.FillDataSet(objDataset, "Author Information")
objConn.Close() '关闭数据链路
objConn = Nothing '清除对象
Authors.DataSource = _
objDataset.Tables("Author Information").DefaultView
Authors.DataBind()
%>
<HTML>
<BODY>
<aspataGrid id="Authors" runat="server"/>
</BODY>
</HTML>
<%@ Import Namespace="System.Data.ADO" %>
<%
'设置连接串...
Dim strConnString as String
strConnString = "Provider=SQLOLEDB;
Data Source=(local);
" &
_
"Initial Catalog=pubs;
User ID=sa"
'创建对象ADOConnection
Dim objConn as ADOConnection
objConn = New ADOConnection
'设置ADOCOnnection对象的连接串
objConn.ConnectionString = strConnString
objConn.Open() '打开数据链路
'创建SQL字符串
Dim strSQL as String = "SELECT * FROM authors"
'创建对象ADODatasetCommand 和Dataset
Dim objDSCommand as ADODatasetCommand
Dim objDataset as Dataset = New Dataset
objDSCommand = New ADODatasetCommand(strSQL, objConn)
'填充数据到Dataset
'并将数据集合命名为 "Author Information"
objDSCommand.FillDataSet(objDataset, "Author Information")
objConn.Close() '关闭数据链路
objConn = Nothing '清除对象
Authors.DataSource = _
objDataset.Tables("Author Information").DefaultView
Authors.DataBind()
%>
<HTML>
<BODY>
<aspataGrid id="Authors" runat="server"/>
</BODY>
</HTML>