con.Open();
string str = "insert into stu(stu_name,stu_psd) values(" + textBox1.Text + "," + textBox2.Text + ")";
SqlCommand cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
//连接语句省略不写了,连接是成功的
我就是VS里拖了2个Textbox控件
一个button控件,然后点击的时候出现
在此上下文中不允许使用名称 "dai"。有效表达式包括常量、常量表达式和变量(在某些上下文中)。不允许使用列名。
string str = "insert into stu(stu_name,stu_psd) values(" + textBox1.Text + "," + textBox2.Text + ")";
SqlCommand cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
//连接语句省略不写了,连接是成功的
我就是VS里拖了2个Textbox控件
一个button控件,然后点击的时候出现
在此上下文中不允许使用名称 "dai"。有效表达式包括常量、常量表达式和变量(在某些上下文中)。不允许使用列名。
解决方案 »
- C#中如何使用BackgroundWorker组件?
- SQL视图统计方法。(应收应付)
- 新人求教,关于c#服务器,Java客户端socket通信问题
- 弱弱的问下什么VS2008中的WPF是什么东东啊
- 怎么样知道我的项目放在哪里??
- 求:关于C# 打印窗口 winform 基本思路 webBrowser
- 发布通用薪资人事管理软件,请接分!
- WINFORM中treeview右击某接点弹出菜单,在右击没有接点的地方还是弹出菜单而且接点还是选中状态,怎么让它不再弹出菜单而且取消接点的选中
- 当改变combobox,要发生什么事件??
- 数组的CopyTo方法的使用?
- 谁有最全的正测表达式??
- XML分析特殊符号的问题。。。
string str = "insert into stu(stu_name,stu_psd) values('" + textBox1.Text + "','" + textBox2.Text + "')";
string str = "insert into stu(stu_name,stu_psd) values('" + textBox1.Text + "','" + textBox2.Text + "')";
SqlCommand cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
con.Close();//用完就关闭
或String.Foramt("insert into stu(stu_name,stu_psd) values('{0}','{1}')",textBox1.Text ,textBox2.Text )