//被调用的类
public static bool add(string sql)
{
bool a = true;
string con = "Data Source=.;Initial Catalog=money;Integrated Security=True";
SqlConnection cnn = new SqlConnection();
cnn.ConnectionString = con;
cnn.Open(); SqlCommand com = new SqlCommand(sql,cnn);
com.ExecuteNonQuery();
return a;
}
//直接执行操作
private void button7_Click(object sender, EventArgs e)
{
string sql = "update liu set 标题='" + textBox3.Text + "',类别='" + comboBox3.Text + "',时间='" + d + "',内容='" + textBox5.Text + "' where 编号='" + aa + "'"; string con = "Data Source=.;Initial Catalog=money;Integrated Security=True";
SqlConnection cnn = new SqlConnection(con);
cnn.Open(); SqlCommand com = new SqlCommand(sql,cnn);
com.ExecuteNonQuery();
cnn.Close();
}
错误提示: 第 1 行: '=' 附近有语法错误。
public static bool add(string sql)
{
bool a = true;
string con = "Data Source=.;Initial Catalog=money;Integrated Security=True";
SqlConnection cnn = new SqlConnection();
cnn.ConnectionString = con;
cnn.Open(); SqlCommand com = new SqlCommand(sql,cnn);
com.ExecuteNonQuery();
return a;
}
//直接执行操作
private void button7_Click(object sender, EventArgs e)
{
string sql = "update liu set 标题='" + textBox3.Text + "',类别='" + comboBox3.Text + "',时间='" + d + "',内容='" + textBox5.Text + "' where 编号='" + aa + "'"; string con = "Data Source=.;Initial Catalog=money;Integrated Security=True";
SqlConnection cnn = new SqlConnection(con);
cnn.Open(); SqlCommand com = new SqlCommand(sql,cnn);
com.ExecuteNonQuery();
cnn.Close();
}
错误提示: 第 1 行: '=' 附近有语法错误。
解决方案 »
- App.Config 问题
- ado操作excel,字段名中包含非法字符的问题
- ico图片为什么有时没有显示在主程序上呢
- Process没有退出?各位帮我一下啊。
- 那位前辈有能下载C#的视屏教程的网站 给个 谢谢~!!!
- datalist分页显示图片的问题。
- c# 怎么获取datagridview中DataGridViewComboBox的显示值(不是value实际值)啊?急
- datagridview有数据加载时候会触发那个事件?
- .net 动态调用WCF 提供的参数不起作用 why????
- 如何屏蔽表单中的关闭按钮?
- .net应用程序打开几次之后怎么越来越慢
- 应用框架(松耦合+模块插拔+模块可定制)讨论
这句有问题,改为:
string sql = "update liu set 标题= ' " + textBox3.Text + " ',类别= ' " + comboBox3.Text + " ',时间= ' " + d + " ',内容= ' " + textBox5.Text + " ' where 编号= ' " + aa + "' ";
where 前加空格 这种错误你不确定就设断点取到str的值,在数据库执行这条语句看有没有问题