I am inserting two values to a table, one from another table and the other from form control but I am getting an error.
我正在向表中插入两个值,一个来自另一个表,另一个来自表单控件但我收到错误。
sqlstr = "INSERT INTO partylinks ( accountid, partyid ) values(Select max(accountsinfo.accid) FROM accountsinfo,2 )"
cmd = New OleDb.OleDbCommand(sqlstr, con, tra)
cmd.ExecuteNonQuery()
1 个解决方案
#1
You don't use the VALUES
syntax if you are SELECT
ing
如果要选择,则不使用VALUES语法
Try:
sqlstr = "INSERT INTO partylinks (accountid, partyid) Select max(accountsinfo.accid),2 AS partyid FROM accountsinfo"
#1
You don't use the VALUES
syntax if you are SELECT
ing
如果要选择,则不使用VALUES语法
Try:
sqlstr = "INSERT INTO partylinks (accountid, partyid) Select max(accountsinfo.accid),2 AS partyid FROM accountsinfo"