Dim cmd As New OleDbCommand("Insert into DDTable" _
& "Values NewMember.ApplicantName, NewMember.ApplicationNo, NewCustomer.ApplicationNo, NewCustomer.PlanName, NewCustomer.AccountNo, NewCustomer.InvestmentAmount, Deposit.InvestmentAmount, NewMember.ProcessingFee, NewCustomer.ProcessingFee, NewMember.IntroducerName, NewMember.IntroducerCode" _
& "SELECT NewMember.ApplicantName, NewMember.ApplicationNo, NewMember.ProcessingFee, NewMember.IntroducerName, NewMember.IntroducerCode From NewMember" _
& "Union All Select NewCustomer.ApplicationNo, NewCustomer.PlanName, NewCustomer.AccountNo, NewCustomer.InvestmentAmount, NewCustomer.ProcessingFee From NewCustomer" _
& "Union All Select Deposit.InvestmentAmount From Deposit" _
& "WHERE NewCustomer.OpeningDate =#" & dtpDates.Text & "# AND Deposit.Date =#" & dtpDates.Text & "# AND NewMember.JoiningDate =#" & dtpDates.Text & "#", con)
cmd.ExecuteNonQuery()
con.Close()
上面的代碼顯示「插入語句中的錯誤」,我只是找不到原因!請幫忙。由於SQL插入語句錯誤
續: 現在我將記錄插入我的數據庫表和代碼是下文一個工作的SQL代碼...
Dim cmd As New OleDbCommand("SELECT NewMember.ApplicantName, NewMember.ApplicationNo, NewMember.ProcessingFee, NewMember.IntroducerName, NewMember.IntroducerCode, NewMember.JoiningDate, NewCustomer.ApplicationNo, NewCustomer.PlanName, NewCustomer.AccountNo, NewCustomer.InvestmentAmount, NewCustomer.ProcessingFees, NewCustomer.OpeningDate, Deposit.Date, Deposit.InvestmentAmount Into DDTable FROM NewMember, NewCustomer, Deposit WHERE NewMember.JoiningDate = NewCustomer.OpeningDate AND NewCustomer.OpeningDate = Deposit.Date;", con)
但最近的問題是,當我使用的DateTimePicker到選擇任何日期然後記錄沒有得到保存。任何想法,任何幫助?
您是否嘗試將該代碼放入sql測試設備?如果我完全理解,那是相當差的sql。 –
連續線不會添加空格。因此查詢擴展爲「Insert into DDTableValues」... – chip
您應該將您的新問題作爲單獨問題發佈。 –