dataset数据集怎么在C#中进行绑定或是连接,才能得到该数据集中的数据啊?

解决方案 »

  1.   


                 string sqlStr = 查询语句
                 SqlDataAdapter daGetData = new SqlDataAdapter(sqlStr, connection);             DataSet dsReturnData = new DataSet();
                 daGetData.Fill(dsReturnData);             Gridview1.datasource=dsReturnData;
                  Gridview1.databind();
      

  2.   

    用DataGrid可以显示,控制它的datasource
      

  3.   

    楼上的能说清点吗?DataGrid显示datasource如何控制啊,像1楼的来点语句啊。我用的是VS2003无Gridview啊。
      

  4.   

    DataGrid显示datasource如何控制啊
    楼主,你把二楼的string sqlStr = 查询语句这个搞好就得啦,SQL的功能很强的啊,想要怎样的结果,就看你的啦. Gridview1.datasource=数据集这样应该可以显示你SQL返回的结果.
      

  5.   

    Gridview1.datasource=myDataset.Tables["表名"];
                  Gridview1.databind();
      

  6.   


    private static string ConnectionString
    {
    get
    {
    return System.Configuration.ConfigurationSettings.AppSettings["connstr"];
    }
    } private DataAccess()
    {
                
    } private static SqlConnection DBConnection
    {
    get
    {
    SqlConnection conn = null;
    try
    {
    conn = new SqlConnection(ConnectionString);
    }
    catch(Exception ex)
    {
    throw new Exception("Error:ExcuteQuery()-->"+ex.Message);
    }
    return conn;
    }
    }
      

  7.   

    public static DataTable GetTable(SqlCommand cmd)
    {
    DataTable dt = null;
    cmd.Connection = DBConnection;
    cmd.Connection.Open();
    SqlDataAdapter dap = new SqlDataAdapter(cmd);
    try
    {
    dt = new DataTable();
    dap.Fill(dt); }
    catch(Exception ex)
    {
    throw new Exception("Error:DataTable()-->"+ex.Message);
    }
    finally
    {
    dap.Dispose();
    }
    return dt;
    }
      

  8.   

    DataGrid1.DataSource = DataAccess.GetTable("SELECT * from t_news");
    DataGrid1.DataBind()
      

  9.   

    好多方法阿!
    可以绑定Gridview1
    还有DropDownList Gridview1.datasource=myDataset;
    Gridview1.databind();DropDownList.datasource = myDataset.Tables[index];
    DropDownList.databind();
      

  10.   

    我这又不是连SQL,我要用VS2003 C#用winform开发的项目连Oracle9i谁来帮帮连下撒。
      

  11.   

    public static DataTable GetTable(SqlCommand cmd)
    {
    DataTable dt = null;
    cmd.Connection = DBConnection;
    cmd.Connection.Open();
    SqlDataAdapter dap = new SqlDataAdapter(cmd);
    try
    {
    dt = new DataTable();
    dap.Fill(dt); }
    catch(Exception ex)
    {
    throw new Exception("Error:DataTable()-->"+ex.Message);
    }
    finally
    {
    dap.Dispose();
    }
    return dt;
    }