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。

解决方案 »

  1.   

    提示 INSERT   INTO   语句的语法错误
    调试一下,把代入值的SQL语句提出来放到Access执行一下,看看语句哪里错误
      

  2.   

    insert   into   User(Uname,Ujob,Upwd,Uemail,Uphone,Uadd)   values('"&   name.text   &"','"&   job.text   &"','"&   pwd.text   &"','"&   email.text   &"','"&   phone.text   &"','"&   add.text   &"')" 
    改成
    insert   into   [User][ 保留关键字的问题,其他的有这个问题都要改
      

  3.   

    把insert into 语句放到Access执行一下,调试一下看一看
      

  4.   

    支持3楼,可能是关键字 User 的问题 ,把他放到"[]",中再运行一下试试
      

  5.   

    要是还是不行,那就是
    '"&       name.text       &"','"&       job.text       &"','"&       pwd.text       &"','"&       email.text       &"','"&       phone.text       &"','"&       add.text       &"'
    这里的问题了 把所有的'单引号去掉