public void BindData()
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data source=(local);initial catalog=Test;user id=sa;pwd=123456;";
conn.Open();
string strCmd = "SELECT * FROM TestOne";
SqlDataAdapter myDataAdapter;
DataSet myDataSet = new DataSet();
myDataAdapter = new SqlDataAdapter(strCmd, conn);
myDataAdapter.Fill(myDataSet, "TestOne");
Label1.Text = myDataSet.Tables[0].Rows[0]["Name"].ToString();
}
说明:数据库:Test ;数据表:TestOne ;表字段:Name