string   sql_connStr   =  "server=10.0.80.204;database=ERP;uid=ERP;pwd=erp";
SqlConnection  sql_conn  =new  SqlConnection(sql_connStr);
sql_conn.Open();
SqlDataAdapter   da=new   SqlDataAdapter("select * from  test  where    ID='" + strID + "'",sql_conn); 
string Sqlstr="select from test where ID='" + strID + "'";
SqlCommand cmd=new SqlCommand(Sqlstr,sql_conn);
cmd.CommandType=CommandType.Text;
// cmd.ExecuteNonQuery();
DataSet   ds=new   DataSet();  
  
da.SelectCommand=cmd;   
da.Fill(ds,"test");
sql_conn.Close();
return ds;

解决方案 »

  1.   

    哦,不好意思我想把数据库里面查到的数据,显示到textBox里面,但是编译通不过,还想问一下我怎么样把得到的数据集显示到textbox里面,我刚做c#谢谢指教。
      

  2.   

    我做了一个webservice 想把通过webservice里面的内容显示到textBox里面去。
      

  3.   

    string   sql_connStr   =  "server=10.0.80.204;database=ERP;uid=ERP;pwd=erp";SqlConnection  sql_conn  =new  SqlConnection(sql_connStr);SqlDataAdapter   da=new   SqlDataAdapter("select * from  test  where    ID='" + strID + "'",sql_conn); DataSet   ds=new   DataSet();  
      
    da.Fill(ds,"test");if(ds.tables[0].Rows.Count !=0)
    {
    this.textBox1.Text = ds.tables[0].rows[0]["ColName"].ToString();
    }
    如果绑定的话 则
    this.textBox1.DataBingdings.Add("Text",ds.tables[0],"ColName");//
    此时将绑定至该ds的ColName的列
      

  4.   

    就如jiatong1981(末日之痕)的代码所写的
    this.textBox1.Text = ds.tables[0].rows[0]["ColName"].ToString();
    这句就实现了