conn = new SqlConnection(connString);
SqlCommand sc = new SqlCommand();
sc.Connection = conn;
sc.CommandText = "select count(*) from FilesInfo ";
conn.Open();
int count = (int)sc.ExecuteScalar();
conn.Close();
sc.CommandText = "select * from FilesInfo where filesName=@filesName";
SqlParameter sp1 = sc.Parameters.Add("@filesName", SqlDbType.VarChar);
sp1.Value = treeView1.SelectedNode.Text;
conn.Open();
SqlDataReader reader = sc.ExecuteReader();
for (int j = count - 1; j >= 0; j--)
{
if (reader.Read())
{
FilesText = reader["filesTxt"].ToString();
FilesID = reader["filesID"].ToString();
textBox1.Text = FilesText;
textBox4.Text = FilesID;
}
}
conn.Close();
上面这段代码就是你想要的!SQL句你得改成适合你自己的!
太基础的东西还是去看书吧
txtbox.text文本框 数据库dt.rows[索引值][索引值].tostring();
txtbox.text=dt.rows[索引值][索引值].tostring();
Over