您是否在以下MySQL查询中发现任何问题。实际上这个Insert查询不起作用。这些工具正确地从FORM控件中选取值,但它没有更新。
MySQL DB中的值未更新。编码正确地带来了表单值,但它没有在MySQL DB中更新 实际上是我在VB.Net(VS2010)中使用的查询
Private Sub btnupdate_Click(sender As System.Object, e As System.EventArgs) Handles btnupdate.Click
Dim ch_date As Date = dtpdate.Value
If ch_date = getToday(Now) Then
checkdate(ch_date)
Else
checkdate(ch_date)
End If
cleanfields()
End Sub
Function checkdate(ByVal chdate As Date)
Dim tmpreader As MySqlDataReader
Dim usr As String
'Dim dtp_date As Date = dtpdate.Value
usr = getUserName()
usr = getFullName(getUserName())
Try
If main_form.mySQLconn1.State = ConnectionState.Closed Then
main_form.mySQLconn1.Open()
End If
main_form.cmdproductivity.CommandText = "SELECT * FROM productivity WHERE productivity_date = @productivity_date"
main_form.cmdproductivity.Parameters("@productivity_date").Value = chdate
tmpreader = main_form.cmdproductivity.ExecuteReader()
If tmpreader.HasRows Then
main_form.cmdproductivity.CommandText = "UPDATE productivity SET agent = @agent, productivity_date = @productivity_date, actual_date = @actual_date, total_count = @total_count, eq_pr = @eq_pr, c_rebook=@c_rebook, c_nonwatson=@c_nonwatson, c_coa=@c_coa, c_watson=@c_watson, c_velocity=@c_velocity, c_quote=@c_quote, c_crd=@c_crd, c_eclaims=@c_eclaims, c_ecalls=@c_ecalls, c_xi=@c_xi, c_brazil=@c_brazil, c_cancel=@c_cancel, c_queries=@c_queries, c_partrebook=@c_partrebook, c_nci=@c_nci, c_phil=@c_phil, c_qc=@c_qc, c_watsonqc=@c_watsonqc, c_monitor=@c_monitor, c_enduser=@c_enduser, c_idoc=@c_idoc, c_servercancel=@c_servercancel, eq_rebook=@eq_rebook, eq_nonwatson=@eq_nonwatson, eq_coa=@eq_coa, eq_watson=@eq_watson, eq_velocity=@eq_velocity, eq_quote=@eq_quote, eq_crd=@eq_crd, eq_eclaims=@eq_eclaims, eq_ecalls=@eq_ecalls, eq_xi=@eq_xi, eq_brazil=@eq_brazil, eq_cancel=@eq_cancel, eq_queries=@eq_queries, eq_partrebook=@eq_partrebook, eq_nci=@eq_nci, eq_phil=@eq_phil, eq_qc=@eq_qc, eq_watsonqc=@eq_watsonqc, eq_monitor=@eq_monitor, eq_enduser=@eq_enduser, eq_idoc=@eq_idoc, eq_servercancel=@eq_servercancel WHERE productivity_date = @productivity_date"
main_form.cmdproductivity.Parameters("@agent").Value = Trim(usr)
main_form.cmdproductivity.Parameters("@productivity_date").Value = Trim(chdate)
main_form.cmdproductivity.Parameters("@actual_date").Value = getToday(Now)
main_form.cmdproductivity.Parameters("@total_count").Value = Trim(txtcount.Text)
main_form.cmdproductivity.Parameters("@eq_pr").Value = Trim(txtEQPRs.Text)
main_form.cmdproductivity.Parameters("@c_rebook").Value = Trim(txtrebook.Text)
main_form.cmdproductivity.Parameters("@c_nonwatson").Value = Trim(txtnonwatson.Text)
main_form.cmdproductivity.Parameters("@c_coa").Value = Trim(txtcoa.Text)
main_form.cmdproductivity.Parameters("@c_watson").Value = Trim(txtwatson.Text)
main_form.cmdproductivity.Parameters("@c_velocity").Value = Trim(txtvelocity.Text)
main_form.cmdproductivity.Parameters("@c_quote").Value = Trim(txtquote.Text)
main_form.cmdproductivity.Parameters("@c_crd").Value = Trim(txtcrd.Text)
main_form.cmdproductivity.Parameters("@c_eclaims").Value = Trim(txteclaims.Text)
main_form.cmdproductivity.Parameters("@c_ecalls").Value = Trim(txtecalls.Text)
main_form.cmdproductivity.Parameters("@c_xi").Value = Trim(txtxi.Text)
main_form.cmdproductivity.Parameters("@c_brazil").Value = Trim(txtbrazil.Text)
main_form.cmdproductivity.Parameters("@c_cancel").Value = Trim(txtcancel.Text)
main_form.cmdproductivity.Parameters("@c_queries").Value = Trim(txtqueries.Text)
main_form.cmdproductivity.Parameters("@c_partrebook").Value = Trim(txtpartrebook.Text)
main_form.cmdproductivity.Parameters("@c_nci").Value = Trim(txtnci.Text)
main_form.cmdproductivity.Parameters("@c_phil").Value = Trim(txtphil.Text)
main_form.cmdproductivity.Parameters("@c_qc").Value = Trim(txtqc.Text)
main_form.cmdproductivity.Parameters("@c_watsonqc").Value = Trim(txtwatsonqc.Text)
main_form.cmdproductivity.Parameters("@c_monitor").Value = Trim(txtmonitor.Text)
main_form.cmdproductivity.Parameters("@c_enduser").Value = Trim(txtenduser.Text)
main_form.cmdproductivity.Parameters("@c_idoc").Value = Trim(txtidoc.Text)
main_form.cmdproductivity.Parameters("@c_servercancel").Value = Trim(txtservercancel.Text)
main_form.cmdproductivity.Parameters("@eq_rebook").Value = Trim(txtEQrebook.Text)
main_form.cmdproductivity.Parameters("@eq_nonwatson").Value = Trim(txtEQnonwatson.Text)
main_form.cmdproductivity.Parameters("@eq_coa").Value = Trim(txtEQcoa.Text)
main_form.cmdproductivity.Parameters("@eq_watson").Value = Trim(txtEQwatson.Text)
main_form.cmdproductivity.Parameters("@eq_velocity").Value = Trim(txtEQvelocity.Text)
main_form.cmdproductivity.Parameters("@eq_quote").Value = Trim(txtEQquote.Text)
main_form.cmdproductivity.Parameters("@eq_crd").Value = Trim(txtEQcrd.Text)
main_form.cmdproductivity.Parameters("@eq_eclaims").Value = Trim(txtEQeclaims.Text)
main_form.cmdproductivity.Parameters("@eq_ecalls").Value = Trim(txtEQecalls.Text)
main_form.cmdproductivity.Parameters("@eq_xi").Value = Trim(txtEQxi.Text)
main_form.cmdproductivity.Parameters("@eq_brazil").Value = Trim(txtEQbrazil.Text)
main_form.cmdproductivity.Parameters("@eq_cancel").Value = Trim(txtEQcancel.Text)
main_form.cmdproductivity.Parameters("@eq_queries").Value = Trim(txtEQqueries.Text)
main_form.cmdproductivity.Parameters("@eq_partrebook").Value = Trim(txtEQpartrebook.Text)
main_form.cmdproductivity.Parameters("@eq_nci").Value = Trim(txtEQnci.Text)
main_form.cmdproductivity.Parameters("@eq_phil").Value = Trim(txtEQphil.Text)
main_form.cmdproductivity.Parameters("@eq_qc").Value = Trim(txtEQqc.Text)
main_form.cmdproductivity.Parameters("@eq_watsonqc").Value = Trim(txtEQwatsonqc.Text)
main_form.cmdproductivity.Parameters("@eq_monitor").Value = Trim(txtEQmonitor.Text)
main_form.cmdproductivity.Parameters("@eq_enduser").Value = Trim(txtEQenduser.Text)
main_form.cmdproductivity.Parameters("@eq_idoc").Value = Trim(txtEQidoc.Text)
main_form.cmdproductivity.Parameters("@eq_servercancel").Value = Trim(txtEQservercancel.Text)
Else
'main_form.cmdproductivity.CommandText = "INSERT INTO productivity " _
' & "(agent,productivity_date,actual_date,total_count,eq_pr,c_rebook,c_nonwatson,c_coa,c_watson,c_velocity,c_quote,c_crd,c_eclaims,c_ecalls,c_xi,c_brazil,c_cancel,c_queries,c_partrebook,c_nci,c_phil,c_qc,c_watsonqc,c_monitor,c_enduser,c_idoc,c_servercancel,eq_rebook,eq_nonwatson,eq_coa,eq_watson,eq_velocity,eq_quote,eq_crd,eq_eclaims,eq_ecallseq_xi,eq_brazil,eq_cancel,eq_queries,eq_partrebook,eq_nci,eq_phil,eq_qc,eq_watsonqc,eq_monitor,eq_enduser,eq_idoc,eq_servercancel VALUES" _
' & "(@agent,@productivity_date,@actual_date,@total_count,@eq_pr,@c_rebook,@c_nonwatson,@c_coa,@c_watson,@c_velocity,@c_quote,@c_crd,@c_eclaims,@c_ecalls,@c_xi,@c_brazil,@c_cancel,@c_queries,@c_partrebook,@c_nci,@c_phil,@c_qc,@c_watsonqc,@c_monitor,@c_enduser,@c_idoc,@c_servercancel,@eq_rebook,@eq_nonwatson,@eq_coa,@eq_watson,@eq_velocity,@eq_quote,@eq_crd,@eq_eclaims,@eq_ecalls,@eq_xi,@eq_brazil,@eq_cancel,@eq_queries,@eq_partrebook,@eq_nci,@eq_phil,@eq_qc,@eq_watsonqc,@eq_monitor,@eq_enduser,@eq_idoc,@eq_servercancel)"
main_form.cmdproductivity.CommandText = "INSERT INTO productivity(agent, productivity_date, actual_date, total_count, eq_pr, c_rebook, c_nonwatson, c_coa, c_watson, c_velocity, c_quote, c_crd, c_eclaims, c_ecalls, c_xi, c_brazil, c_cancel, c_queries, c_partrebook, c_nci, c_phil, c_qc, c_watsonqc, c_monitor, c_enduser, c_idoc, c_servercancel, eq_rebook, eq_nonwatson, eq_coa, eq_watson, eq_velocity, eq_quote, eq_crd, eq_eclaims, eq_ecalls, eq_xi, eq_brazil, eq_cancel, eq_queries, eq_partrebook, eq_nci, eq_phil, eq_qc, eq_watsonqc, eq_monitor, eq_enduser, eq_idoc, eq_servercancel) VALUES (@agent,@productivity_date,@actual_date,@total_count,@eq_pr,@c_rebook,@c_nonwatson,@c_coa,@c_watson,@c_velocity,@c_quote,@c_crd,@c_eclaims,@c_ecalls,@c_xi,@c_brazil,@c_cancel,@c_queries,@c_partrebook,@c_nci,@c_phil,@c_qc,@c_watsonqc,@c_monitor,@c_enduser,@c_idoc,@c_servercancel,@eq_rebook,@eq_nonwatson,@eq_coa,@eq_watson,@eq_velocity,@eq_quote,@eq_crd,@eq_eclaims,@eq_ecalls,@eq_xi,@eq_brazil,@eq_cancel,@eq_queries,@eq_partrebook,@eq_nci,@eq_phil,@eq_qc,@eq_watsonqc,@eq_monitor,@eq_enduser,@eq_idoc,@eq_servercancel)"
main_form.cmdproductivity.Parameters("@agent").Value = Trim(usr)
main_form.cmdproductivity.Parameters("@productivity_date").Value = Trim(chdate)
main_form.cmdproductivity.Parameters("@actual_date").Value = getToday(Now)
main_form.cmdproductivity.Parameters("@total_count").Value = Trim(txtcount.Text)
main_form.cmdproductivity.Parameters("@eq_pr").Value = Trim(txtEQPRs.Text)
main_form.cmdproductivity.Parameters("@c_rebook").Value = Trim(txtrebook.Text)
main_form.cmdproductivity.Parameters("@c_nonwatson").Value = Trim(txtnonwatson.Text)
main_form.cmdproductivity.Parameters("@c_coa").Value = Trim(txtcoa.Text)
main_form.cmdproductivity.Parameters("@c_watson").Value = Trim(txtwatson.Text)
main_form.cmdproductivity.Parameters("@c_velocity").Value = Trim(txtvelocity.Text)
main_form.cmdproductivity.Parameters("@c_quote").Value = Trim(txtquote.Text)
main_form.cmdproductivity.Parameters("@c_crd").Value = Trim(txtcrd.Text)
main_form.cmdproductivity.Parameters("@c_eclaims").Value = Trim(txteclaims.Text)
main_form.cmdproductivity.Parameters("@c_ecalls").Value = Trim(txtecalls.Text)
main_form.cmdproductivity.Parameters("@c_xi").Value = Trim(txtxi.Text)
main_form.cmdproductivity.Parameters("@c_brazil").Value = Trim(txtbrazil.Text)
main_form.cmdproductivity.Parameters("@c_cancel").Value = Trim(txtcancel.Text)
main_form.cmdproductivity.Parameters("@c_queries").Value = Trim(txtqueries.Text)
main_form.cmdproductivity.Parameters("@c_partrebook").Value = Trim(txtpartrebook.Text)
main_form.cmdproductivity.Parameters("@c_nci").Value = Trim(txtnci.Text)
main_form.cmdproductivity.Parameters("@c_phil").Value = Trim(txtphil.Text)
main_form.cmdproductivity.Parameters("@c_qc").Value = Trim(txtqc.Text)
main_form.cmdproductivity.Parameters("@c_watsonqc").Value = Trim(txtwatsonqc.Text)
main_form.cmdproductivity.Parameters("@c_monitor").Value = Trim(txtmonitor.Text)
main_form.cmdproductivity.Parameters("@c_enduser").Value = Trim(txtenduser.Text)
main_form.cmdproductivity.Parameters("@c_idoc").Value = Trim(txtidoc.Text)
main_form.cmdproductivity.Parameters("@c_servercancel").Value = Trim(txtservercancel.Text)
main_form.cmdproductivity.Parameters("@eq_rebook").Value = Trim(txtEQrebook.Text)
main_form.cmdproductivity.Parameters("@eq_nonwatson").Value = Trim(txtEQnonwatson.Text)
main_form.cmdproductivity.Parameters("@eq_coa").Value = Trim(txtEQcoa.Text)
main_form.cmdproductivity.Parameters("@eq_watson").Value = Trim(txtEQwatson.Text)
main_form.cmdproductivity.Parameters("@eq_velocity").Value = Trim(txtEQvelocity.Text)
main_form.cmdproductivity.Parameters("@eq_quote").Value = Trim(txtEQquote.Text)
main_form.cmdproductivity.Parameters("@eq_crd").Value = Trim(txtEQcrd.Text)
main_form.cmdproductivity.Parameters("@eq_eclaims").Value = Trim(txtEQeclaims.Text)
main_form.cmdproductivity.Parameters("@eq_ecalls").Value = Trim(txtEQecalls.Text)
main_form.cmdproductivity.Parameters("@eq_xi").Value = Trim(txtEQxi.Text)
main_form.cmdproductivity.Parameters("@eq_brazil").Value = Trim(txtEQbrazil.Text)
main_form.cmdproductivity.Parameters("@eq_cancel").Value = Trim(txtEQcancel.Text)
main_form.cmdproductivity.Parameters("@eq_queries").Value = Trim(txtEQqueries.Text)
main_form.cmdproductivity.Parameters("@eq_partrebook").Value = Trim(txtEQpartrebook.Text)
main_form.cmdproductivity.Parameters("@eq_nci").Value = Trim(txtEQnci.Text)
main_form.cmdproductivity.Parameters("@eq_phil").Value = Trim(txtEQphil.Text)
main_form.cmdproductivity.Parameters("@eq_qc").Value = Trim(txtEQqc.Text)
main_form.cmdproductivity.Parameters("@eq_watsonqc").Value = Trim(txtEQwatsonqc.Text)
main_form.cmdproductivity.Parameters("@eq_monitor").Value = Trim(txtEQmonitor.Text)
main_form.cmdproductivity.Parameters("@eq_enduser").Value = Trim(txtEQenduser.Text)
main_form.cmdproductivity.Parameters("@eq_idoc").Value = Trim(txtEQidoc.Text)
main_form.cmdproductivity.Parameters("@eq_servercancel").Value = Trim(txtEQservercancel.Text)
End If
Catch ex As Exception
MsgBox("Database Error: " & ex.ToString() & vbCrLf & "The error have been logged .... ", MsgBoxStyle.OkOnly, main_form.dbErrTitle)
writeLogs("Database Error: " & ex.ToString())
Finally
main_form.mySQLconn1.Close()
End Try
Return True
End Function
答案 0 :(得分:0)
我不计算您的列号,但是您最后会错过一列吗?哪个是列中存在但不在VALUSE部分中的最后一个id: (eq_servercancel,id)vs (@eq_servercancel)
答案 1 :(得分:0)
如果你用你得到的错误编辑你的答案会很有帮助,但一目了然:
您正在INSERT语句中向列列表添加“id”,但VALUES语句中没有“id”值。因此要么从INSERT语句中删除“id”,要么通过“id”的值发送。