sql database problem
-
hi .i have problem connecting the database to the textbox SqlConnection cnn = new SqlConnection("server=(local); database=pubs;Integrated Security=SSPI"); SqlDataAdapter da = new SqlDataAdapter("select * from authors", cnn); DataSet ds = new DataSet(); da.Fill(ds); if i settle the connection above.. how do i connect the data from table authors e.g. 'name' to the textbox.. this.textbox.text = ???????
-
hi .i have problem connecting the database to the textbox SqlConnection cnn = new SqlConnection("server=(local); database=pubs;Integrated Security=SSPI"); SqlDataAdapter da = new SqlDataAdapter("select * from authors", cnn); DataSet ds = new DataSet(); da.Fill(ds); if i settle the connection above.. how do i connect the data from table authors e.g. 'name' to the textbox.. this.textbox.text = ???????
-
datatable's function is to get one record .. DataTable table999; string command = "select * from Table1"; SqlDataAdapter father = new SqlDataAdapter(command, myConnection); DataSet son = new DataSet(); father.Fill(son,"Table1"); table999 = son.Tables["Table1"]; this.aaa.Text= table999.Rows[0]["name"].ToString(); it said tat the father.fill(son,"Table1") got problem
-
datatable's function is to get one record .. DataTable table999; string command = "select * from Table1"; SqlDataAdapter father = new SqlDataAdapter(command, myConnection); DataSet son = new DataSet(); father.Fill(son,"Table1"); table999 = son.Tables["Table1"]; this.aaa.Text= table999.Rows[0]["name"].ToString(); it said tat the father.fill(son,"Table1") got problem
Because the table name is the one you added in the dataset: DataTable table999; string command = "select * from Table1"; SqlDataAdapter father = new SqlDataAdapter(command, myConnection); DataSet son = new DataSet(); son.Tables.Add("Table1"); father.Fill(son, "Table1"); ... That's work. But there has only one select statement in your case, why don't you use the index rather than table name?
-
Because the table name is the one you added in the dataset: DataTable table999; string command = "select * from Table1"; SqlDataAdapter father = new SqlDataAdapter(command, myConnection); DataSet son = new DataSet(); son.Tables.Add("Table1"); father.Fill(son, "Table1"); ... That's work. But there has only one select statement in your case, why don't you use the index rather than table name?