在Visual Basic中插入INNER JOIN

时间:2016-08-28 14:23:07

标签: mysql vb.net vb.net-2010

我使用INSERT INTO INNER JOIN语句,因为我需要将table1中的一些数据也插入到table2中。但我得到"OLEDbExceptionUnhandled: Missing semicolon (;) at end of SQL statement."的错误但是我无法弄清楚这个分号应该在哪里。希望有人可以帮助我。

ff是我的代码:

Dim cmd As OleDbCommand = New OleDbCommand("INSERT INTO Table1
(Check_No,Voucher_No,Issue_Date,Company_Name,Bank_Type, 
Amount_in_Figure,Amount_in_Words,Payee,Particulars,Remarks) 
VALUES('" & Me.txtCheckNo.Text & "','" & Me.txtVoucherNo.Text & "', '" & 
Me.dtpDate.Text & "', '" & Me.txtCompName.Text & "', '" & 
Me.txtBankType.Text & "','" & Me.txtAmtInFigure.Text & "','" & 
Me.txtAmtInWords.Text & "','" & Me.txtPayTo.Text & "','" & 
Me.txtParticulars.Text & "','" & Me.cmbRemarks.SelectedItem & "') 
SELECT ID,Check_No,Voucher_No 
FROM Table1 INNER JOIN Table2 AS vNo ON Table1.Check_No = vNo.Check_Number, 
Table1.Voucher_No = vNo.Voucher_Number, Table1.ID = vNo.CompanyID", 
myConnection)

myConnection.Open()
cmd.ExecuteNonQuery()
myConnection.Close()

1 个答案:

答案 0 :(得分:0)

  

但是我无法弄清楚这个分号应该在哪里。

在此之前:

SELECT ID,Check_No,Voucher_No