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;
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;
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的列
this.textBox1.Text = ds.tables[0].rows[0]["ColName"].ToString();
这句就实现了