public partial class Form3 : Form
{
public Form3(string str)
{
InitializeComponent();
this.id.Text = str;
SqlConnection Conn = new SqlConnection("Server=localhost;DataBase=学生成绩;Integrated Security =SSPI"); //建立数据库实例..
Conn.Open(); //打开数据库
SqlCommand Cmd = new SqlCommand();
Cmd.Connection = Conn;
Cmd.CommandType = CommandType.Text;
Cmd.CommandText = "select 姓名,语文,数学,英语 from 学生成绩 where 学号=str";
Cmd.ExecuteNonQuery(); //执行sql语句...
Conn.Close();
}
查询代码如上,就是不能通过
请帮忙解决一下
SqlConnection Conn = new SqlConnection("Server=localhost;DataBase=学生成绩;Integrated Security =SSPI"); //建立数据库实例..
Conn.Open(); //打开数据库
SqlCommand Cmd = new SqlCommand();
Cmd.Connection = Conn;
Cmd.CommandType = CommandType.Text;
Cmd.CommandText = "insert into 学生成绩 values(" + this.textBox1.Text + ",'" + this.textBox2.Text + "'," + this.textBox3.Text + "," + this.textBox4.Text + "," + this.textBox5 + ")";
Cmd.ExecuteNonQuery(); //执行sql语句...
Conn.Close();
MessageBox.Show(this,"charuchenggong");
这是插入的语句