<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Oledb" %>
<Script Language="C#" Runat="Server">
public void Page_Load(Object src,EventArgs e)
{
//各种String的设置
string MyConnString = "Provider=SQLOLEDB;server=(local);database=USD;UId=sa;Pwd=";
string strSel1 = "select * from UDS_Class";
string strSel2 = "select * from UDS_Flow";
string strSel3 = "select * from UDS_Role";

DataSet MyDataSet = new DataSet();
OleDbConnection MyConnection = new OleDbConnection(MyConnString);

//打开DataAdapter
OleDbDataAdapter MyAdapter1 = new OleDbDataAdapter(strSel1,MyConnection);
OleDbDataAdapter MyAdapter2 = new OleDbDataAdapter(strSel2,MyConnection);
OleDbDataAdapter MyAdapter3 = new OleDbDataAdapter(strSel3,MyConnection);

//将各表的数据,存入DataSet
MyAdapter1.Fill(MyDataSet,"UDS_Class");
MyAdapter1.Fill(MyDataSet,"UDS_Flow");
MyAdapter1.Fill(MyDataSet,"UDS_Role");

//交给DataGrid显示数据
DataGrid1.DataSource = MyDataSet.Tables["UDS_Class"].DefaultView;
DataGrid1.DataSource = MyDataSet.Tables["UDS_Flow"].DefaultView;
DataGrid1.DataSource = MyDataSet.Tables["UDS_Role"].DefaultView;
DataGrid1.DataBind();
DataGrid2.DataBind();
DataGrid3.DataBind();

}</Script><html>
<head><title>测试DataSet</title></head>
<body>
<form runat="server">
<ASP:DataGrid id="DataGrid1" runat="server" AllowPaging="True" PageSize="5" PagerStyle-Mode="NumericPages" BorderColor="black" BorderWidth="1" GridLines="Both" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size"8pt" HeaderStyle-BackColor="#aaaadd" AlternatingItemStyle-BackColor="#eeeeee"/>
<hr>
<ASP:DataGrid id="DataGrid2" runat="server" AllowPaging="True" PageSize="4" PagerStyle-Mode="NumericPages" BorderColor="black" BorderWidth="1" GridLines="Both" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size"8pt" HeaderStyle-BackColor="#aaaadd" AlternatingItemStyle-BackColor="#eeeeee"/>
<hr>
<ASP:DataGrid id="DataGrid3" runat="server" AllowPaging="True" PageSize="4" PagerStyle-Mode="NumericPages" BorderColor="black" BorderWidth="1" GridLines="Both" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size"8pt" HeaderStyle-BackColor="#aaaadd" AlternatingItemStyle-BackColor="#eeeeee"/>
</form>
</body>
</html>

解决方案 »

  1.   

        //将各表的数据,存入DataSet
        MyAdapter1.Fill(MyDataSet,"UDS_Class");
        MyAdapter1.Fill(MyDataSet,"UDS_Flow");
        MyAdapter1.Fill(MyDataSet,"UDS_Role");
        //将各表的数据,存入DataSet
        MyAdapter1.Fill(MyDataSet,"UDS_Class");
        MyAdapter2.Fill(MyDataSet,"UDS_Flow");
        MyAdapter3.Fill(MyDataSet,"UDS_Role");
      

  2.   

        //交给DataGrid显示数据
        DataGrid1.DataSource = MyDataSet.Tables["UDS_Class"].DefaultView;
        DataGrid1.DataSource = MyDataSet.Tables["UDS_Flow"].DefaultView;
        DataGrid1.DataSource = MyDataSet.Tables["UDS_Role"].DefaultView;    //交给DataGrid显示数据
        DataGrid1.DataSource = MyDataSet.Tables["UDS_Class"].DefaultView;
        DataGrid2.DataSource = MyDataSet.Tables["UDS_Flow"].DefaultView;
        DataGrid3.DataSource = MyDataSet.Tables["UDS_Role"].DefaultView;
      

  3.   

    没有MyConnection.Open();记得Close()
    最好用try catch  或 using最好用SqlConnection......
    看别人的代码把
    到www.51aspx.com 下载一个留言板什么的看看
    你很多地方都要注意
      

  4.   

    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.Oledb" %>
    <Script Language="C#" Runat="Server">
    public void Page_Load(Object src,EventArgs e)
    {
    //各种String的设置
    string MyConnString = "Provider=SQLOLEDB;server=(local);database=USD;UId=sa;Pwd=";
    string strSel1 = "select * from UDS_Class";
    string strSel2 = "select * from UDS_Flow";
    string strSel3 = "select * from UDS_Role";

    DataSet MyDataSet = new DataSet();
    OleDbConnection MyConnection = new OleDbConnection(MyConnString);

    //打开DataAdapter
    OleDbDataAdapter MyAdapter1 = new OleDbDataAdapter(strSel1,MyConnection);
    OleDbDataAdapter MyAdapter2 = new OleDbDataAdapter(strSel2,MyConnection);
    OleDbDataAdapter MyAdapter3 = new OleDbDataAdapter(strSel3,MyConnection);

    //将各表的数据,存入DataSet
    MyAdapter1.Fill(MyDataSet,"UDS_Class");
    MyAdapter2.Fill(MyDataSet,"UDS_Flow");
    MyAdapter3.Fill(MyDataSet,"UDS_Role");

    //交给DataGrid显示数据
    DataGrid1.DataSource = MyDataSet.Tables["UDS_Class"].DefaultView;
    DataGrid2.DataSource = MyDataSet.Tables["UDS_Flow"].DefaultView;
    DataGrid3.DataSource = MyDataSet.Tables["UDS_Role"].DefaultView;
    DataGrid1.DataBind();
    DataGrid2.DataBind();
    DataGrid3.DataBind();

    }</Script><html>
    <head><title>测试DataSet</title></head>
    <body>
    <form runat="server">
    <ASP:DataGrid id="DataGrid1" runat="server" AllowPaging="True" PageSize="5" PagerStyle-Mode="NumericPages" BorderColor="black" BorderWidth="1" GridLines="Both" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size"8pt" HeaderStyle-BackColor="#aaaadd" AlternatingItemStyle-BackColor="#eeeeee"/>
    <hr>
    <ASP:DataGrid id="DataGrid2" runat="server" AllowPaging="True" PageSize="4" PagerStyle-Mode="NumericPages" BorderColor="black" BorderWidth="1" GridLines="Both" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size"8pt" HeaderStyle-BackColor="#aaaadd" AlternatingItemStyle-BackColor="#eeeeee"/>
    <hr>
    <ASP:DataGrid id="DataGrid3" runat="server" AllowPaging="True" PageSize="4" PagerStyle-Mode="NumericPages" BorderColor="black" BorderWidth="1" GridLines="Both" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size"8pt" HeaderStyle-BackColor="#aaaadd" AlternatingItemStyle-BackColor="#eeeeee"/>
    </form>
    </body>
    </html>
      

  5.   

    “/”应用程序中的服务器错误。
    --------------------------------------------------------------------------------分析器错误 
    说明: 在分析向此请求提供服务所需资源时出错。请检查下列特定分析错误详细信息并适当地修改源文件。 分析器错误信息: 服务器标记的格式不正确。源错误: 
    行 40: <body>
    行 41: <form runat="server">
    行 42: <ASP:DataGrid id="DataGrid1" runat="server" AllowPaging="True" PageSize="5" PagerStyle-Mode="NumericPages" BorderColor="black" BorderWidth="1" GridLines="Both" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size"8pt" HeaderStyle-BackColor="#aaaadd" AlternatingItemStyle-BackColor="#eeeeee"/>
    行 43: <hr>
    行 44: <ASP:DataGrid id="DataGrid2" runat="server" AllowPaging="True" PageSize="4" PagerStyle-Mode="NumericPages" BorderColor="black" BorderWidth="1" GridLines="Both" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size"8pt" HeaderStyle-BackColor="#aaaadd" AlternatingItemStyle-BackColor="#eeeeee"/>
     源文件: C:\Inetpub\wwwroot\DataSet1.aspx    行: 42 
    --------------------------------------------------------------------------------
    版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573 
      

  6.   

    服务器标记的格式不正确
    提示的很清楚<ASP:DataGrid xxxxx xxxxx >
    </ASP:DataGrid>
      

  7.   

    绑定gridview数据源的时候id都绑错了
      

  8.   

    Font-Size"8pt"
    这里没有等号
    应该是Font-Size="8pt"