SqlConnection thisConnection = new SqlConnection(
"Server=LENOVO-3927D0AD\\SQLEXPRESS;Integrated Security=True;" + "Database=stu");
thisAdapter = new SqlDataAdapter("select f_username[用户名],f_password[密码],f_limit[权限] from t_user", thisConnection);
SqlCommandBuilder thisBuilder = new SqlCommandBuilder(thisAdapter); thisAdapter.Fill(thisDataSet, "t_user");
dataGridView1.DataSource = thisDataSet.Tables[0]; }
private void button1_Click(object sender, EventArgs e) { try {
SqlConnection thisConnection = new SqlConnection(
"Server=LENOVO-3927D0AD\\SQLEXPRESS;Integrated Security=True;" + "Database=stu"); thisConnection.Open();
SqlCommand thisCommand = thisConnection.CreateCommand();
http://www.77cn.com.cnmandText = "insert into t_user(f_username,f_password,f_limit) values('" +
textBox1.Text.ToString().Trim() + "','" + textBox2.Text.ToString().Trim() + "','" + textBox3.Text.ToString().Trim() + "')"; thisCommand.ExecuteNonQuery();
thisAdapter = new SqlDataAdapter("select f_username[用户名],f_password[密码],f_limit[权限] from t_user", thisConnection); thisDataSet.Clear();
SqlCommandBuilder thisBuilder = new SqlCommandBuilder(thisAdapter); thisAdapter.Fill(thisDataSet, "t_user");
dataGridView1.DataSource = thisDataSet.Tables[0]; } catch
{ MessageBox.Show("请检查输入格式是否正确?"); } }
private void button3_Click(object sender, EventArgs e) {
SqlConnection thisConnection = new SqlConnection(
"Server=LENOVO-3927D0AD\\SQLEXPRESS;Integrated Security=True;" + "Database=stu"); thisConnection.Open();
SqlCommand thisCommand = thisConnection.CreateCommand();
http://www.77cn.com.cnmandText = "delete from t_user(f_username,f_password,f_limit) values('" +