请问下我下面语句的单引号和双引号
private void button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "server = CHEN ; uid = sa; pwd =;database = tb";
conn.Open();
string SqlIns = "insert into tb_06 values('" + textBox1.Text + "," + textBox2.Text + "," + textBox3.Text + "')";
SqlCommand command = new SqlCommand();
command.CommandText = SqlIns;
command.Connection = conn;
command.ExecuteNonQuery();
MessageBox.Show("数据添加成功!");
SqlDataAdapter AdapterSelect = new SqlDataAdapter("select * from tb_01", conn);
DataTable dt = new DataTable();
AdapterSelect.Fill(dt);
dataGridView1.DataSource = dt.DefaultView;
}
catch (Exception ee)
{
MessageBox.Show(ee.Message.ToString());
}
}
大家好,我是个新接触C#不久的新手,也许我问题对高手来说不算什么,但我现在是摸索期~~
请问,红色字体那句有很多单引号和双引号的要怎么解释,我照着书打出来的,但是不知道书里印刷的单引号和双引号是不是像我打的那样,因为书里印起来像3个单引号连在一起。
还有,我那个程序主要是编写个FORM窗口,然后可以按Button键添加数据到SQL数据库里。
我照着上面的程序进行了调试,没发现错误,但是运行时,我填好资料按Button键时,弹出错误信息“插入错误:列名或所提供的值的数目与表定义不匹配” 是不是我那句单引号和双引号混合的那句搞错语法了。