我希望在表VOTED(vID)中将Table1(vID)的值设置为自动传输,而查询有一个选择并插入这是我正在尝试的但我无法得到它修复请帮助。
Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles Button1.Click
Try
Dim cmd As New OleDb.OleDbCommand
If Not cnn.State = ConnectionState.Open Then
cnn.Open()
End If
cmd.Connection = cnn
cmd.CommandText = "INSERT INTO VOTED(vID) " & _
" VALUES (" & _
"SELECT(vID) FROM Table1 " & _
" WHERE (" & position & ")"
cmd.ExecuteNonQuery()
cnn.Close()
MessageBox.Show("Inserted sucessfully")
refreshdata()
Catch ex As OleDbException When ex.ErrorCode = -2147467259
MsgBox("FAILED")
End Try
End Sub
答案 0 :(得分:0)
所以'SELECT(vID)FROM Table1 WHERE(来自Table1,1的SELECT vID)'。不是有效的SQL语句。这就是它说“语法错误”的原因。 也许给我发送一个用于表设计的tsql DDL脚本以及你想要完成的任务。