asp.net问题,这段代码是连接SQL数据库,怎么不显示数据,急,才学 (10分)

  • 主题发起人 主题发起人 small pig
  • 开始时间 开始时间
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);
" &amp;
_
"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>
<asp:DataGrid id="Authors" runat="server"/>
</BODY>
</HTML>
 

<%
objConn.Close() '关闭数据链路
objConn = Nothing '清除对象
%>
放在</HTML>下面
 
接受答案了.
 
后退
顶部