a.aspx文件代码如下:<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="第4个页面.aspx.vb" Inherits="server.第四个页面"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>第四个页面</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
Dim DS As DataSet
Dim MyConnection As SQLConnection
Dim MyCommand As SQLDataSetCommand
‘同数据库进行连接,采用sql server数据库
MyConnection = new SQLConnection("server='ntserver';uid=sa;pwd=;database=info")
‘执行SQL操作
MyCommand = New SQLDataSetCommand("select * from infor",MyConnection)
DS = New DataSet()
MyCommand.FillDataSet(ds, "infor")
MyDataGrid.DataSource=ds.Tables("infor").DefaultView
MyDataGrid.DataBind()
End Sub
</script>
</HEAD>
<body>
<center>
<h3><font face="Verdana">Page_load事件演示</font></h3>
<ASP:DataGrid id="MyDataGrid" runat="server" Width="600" BackColor="white" BorderColor="black"
ShowFooter="false" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd"
MaintainState="false" />
</center>
</body>
</HTML>
运行提示错误:
编译器错误信息: BC30002: 未定义类型“SQLDataSetCommand”。
<%@ Import Namespace="System.Data" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="第4个页面.aspx.vb" Inherits="server.第四个页面"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>第四个页面</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
Dim DS As DataSet
Dim MyConnection As SQLConnection
Dim MyCommand As SQLDataSetCommand
‘同数据库进行连接,采用sql server数据库
MyConnection = new SQLConnection("server='ntserver';uid=sa;pwd=;database=info")
‘执行SQL操作
MyCommand = New SQLDataSetCommand("select * from infor",MyConnection)
DS = New DataSet()
MyCommand.FillDataSet(ds, "infor")
MyDataGrid.DataSource=ds.Tables("infor").DefaultView
MyDataGrid.DataBind()
End Sub
</script>
</HEAD>
<body>
<center>
<h3><font face="Verdana">Page_load事件演示</font></h3>
<ASP:DataGrid id="MyDataGrid" runat="server" Width="600" BackColor="white" BorderColor="black"
ShowFooter="false" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd"
MaintainState="false" />
</center>
</body>
</HTML>
运行提示错误:
编译器错误信息: BC30002: 未定义类型“SQLDataSetCommand”。
SQLDataSetCommand错了,应该是SqlCommand吧
Dim DS As DataSet
Dim MyConnection As SQLConnection
Dim MyAdapter As SQLDataAdapter
‘同数据库进行连接,采用sql server数据库
MyConnection = new SQLConnection("server='ntserver';uid=sa;pwd=;database=info")
‘执行SQL操作
MyAdapter = New SQLDataAdapter("select * from infor",MyConnection)
DS = New DataSet()
MyAdapter.Fill(ds, "infor")
MyDataGrid.DataSource=ds.Tables("infor").DefaultView
MyDataGrid.DataBind()
End Sub
SqlConnection conn=new SqlConnection("server='ntserver';uid=sa;pwd=;database=info");
string sqlStr="select * from tableName"
SqlDataAdapter dataAdapter=new SqlDataAdapter(sqlStr,conn);
DataSet ds=new DataSet();
dataAdapter.Fill(ds);
.
.
.
.
.
.