sub Button_Click( s as object,e as eventargs)
if name.text="" or job.text="" or pwd.text="" or email.text="" or phone.text="" or add.text="" then
msg.text="*请输入完整资料!"
else
dim sqlstr as string
dim myconn as OleDbConnection
myconn=new OleDbConnection(System.Configuration.ConfigurationSettings.AppSettings("connstr").ToString())
sqlstr="insert into User(Uname,Ujob,Upwd,Uemail,Uphone,Uadd) values('"& name.text &"','"& job.text &"','"& pwd.text &"','"& email.text &"','"& phone.text &"','"& add.text &"')"
myconn.open()
dim mycomm as new OleDbCommand(sqlstr,myconn)
mycomm.ExecuteNonQuery()
myconn.close()
msg.text="*资料已更新!"
name.text=""
job.text=""
pwd.text=""
email.text=""
phone.text=""
add.text=""
end if
end sub当我点击确定后他就显示 INSERT INTO 语句的语法错误。
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Data.OleDb.OleDbException: INSERT INTO 语句的语法错误。Source Error:Line 19: myconn.open()
Line 20: dim mycomm as new OleDbCommand(sqlstr,myconn)
Line 21: mycomm.ExecuteNonQuery()
Line 22: myconn.close()可是这段代码我是在其他可以正确运行的网站那里拿过来的,那些是我以前写的,是可以正常运行的啊,可是一放到这个网站里就不行了。数据库都是Access。
if name.text="" or job.text="" or pwd.text="" or email.text="" or phone.text="" or add.text="" then
msg.text="*请输入完整资料!"
else
dim sqlstr as string
dim myconn as OleDbConnection
myconn=new OleDbConnection(System.Configuration.ConfigurationSettings.AppSettings("connstr").ToString())
sqlstr="insert into User(Uname,Ujob,Upwd,Uemail,Uphone,Uadd) values('"& name.text &"','"& job.text &"','"& pwd.text &"','"& email.text &"','"& phone.text &"','"& add.text &"')"
myconn.open()
dim mycomm as new OleDbCommand(sqlstr,myconn)
mycomm.ExecuteNonQuery()
myconn.close()
msg.text="*资料已更新!"
name.text=""
job.text=""
pwd.text=""
email.text=""
phone.text=""
add.text=""
end if
end sub当我点击确定后他就显示 INSERT INTO 语句的语法错误。
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Data.OleDb.OleDbException: INSERT INTO 语句的语法错误。Source Error:Line 19: myconn.open()
Line 20: dim mycomm as new OleDbCommand(sqlstr,myconn)
Line 21: mycomm.ExecuteNonQuery()
Line 22: myconn.close()可是这段代码我是在其他可以正确运行的网站那里拿过来的,那些是我以前写的,是可以正常运行的啊,可是一放到这个网站里就不行了。数据库都是Access。
解决方案 »
- 使用VS2008创建Setup Project程序
- webform的DataView控件使用的问题
- StringBuilder的问题
- 程序文件夹为什么会有个圈,圈里还要叹号,求解啊!
- 使用WINDOWS 2003 IIS自带STMP服务器+ASP.NET能不能开发出企业应用级邮件系统
- 弱弱的问一下项目发布的问题,请高手讲详细一点
- 服务器提交了协议冲突. Section=ResponseStatusLine
- 下载的问题! 急! 在线等
- 如何得到__doPostBack('Batch:_ctl54:_ctl1','')的返回结果。xmlhttp
- 游戏兼开发高手请进——怎么让玩游戏的人不堕落
- ?????再送50分,求教高手,AjaxControlToolkit中的问题.....
- session 高手进,如何在sqlserver里获取信息?
调试一下,把代入值的SQL语句提出来放到Access执行一下,看看语句哪里错误
改成
insert into [User][ 保留关键字的问题,其他的有这个问题都要改
'"& name.text &"','"& job.text &"','"& pwd.text &"','"& email.text &"','"& phone.text &"','"& add.text &"'
这里的问题了 把所有的'单引号去掉