含有参数变量的sql语句,如何用C#语句表示。

2025-03-26 05:46:21
推荐回答(2个)
回答1:

string mysql = string.Format("SELECT Cname,Grade FROM student,score,course WHERE student.Sno = score.Sno and score.Cno = course.Cno and student.Sno = '{0}' and score.Text = {1}",textbox1.Text,ComboBox1.Text);


回答2:

string mysql = "SELECT Cname,Grade FROM student,score,course WHERE student.Sno = score.Sno and score.Cno = course.Cno and student.Sno =‘" +Convert.ToString(textBox1.Text) +"’ and score.Text =‘" + Convert.ToInt32(comboBox1.Text)“’;”;