添加数据时报错
try
{
conn = new SqlConnection( "Data Source=cpt-16;Initial Catalog=client;User ID=sa ");
conn.Open();
if (conn.State.ToString ()== "Close ")
{
conn.Open();
}
SqlCommand cmd = new SqlCommand( "Insert into worker_info(workername,workersex,ptime,gtime)values( ' " + textBox1.Text + " ' , ' " + comboBox1.Text + " ' , ' " + textBox2.Text + " ' , ' " + textBox3.Text + " ') ", conn);
// cmd.CommandText = "Insert into worker_info(workername,workersex,ptime,gtime)values( ' " + textBox1.Text + " ', ' " + comboBox1.Text + " ', ' " + textBox2.Text + " ', ' " + textBox3.Text + " ')) ";
cmd.ExecuteNonQuery();
}
请高手帮忙看看有什么错误
------解决方案--------------------values前后加空格试试!