|
-
Aug 6th, 2012, 01:32 PM
#1
Thread Starter
New Member
Fatal error encountered during command execution.
Hi Guys,
I'm not so good at VB and I encountered this prob:
*****
MySql.Data.MySqlClient.MySqlException was unhandled
ErrorCode=-2147467259
Message="Fatal error encountered during command execution."
Number=0
Source="MySql.Data"
StackTrace:
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at LibrojoSystems.frmBillingSystemMain.LibrojoReports() in D:\Lito SJ\Developer\Visual Basic\Projects\Billing System\Billing System\frmBillingSystemMain.vb:line 532
at LibrojoSystems.frmBillingSystemMain.CMDRepBillRep_Bill_Click(Object sender, EventArgs e) in D:\Lito SJ\Developer\Visual Basic\Projects\Billing System\Billing System\frmBillingSystemMain.vb:line 458
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at LibrojoSystems.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: MySql.Data.MySqlClient.MySqlException
ErrorCode=-2147467259
Message="Parameter '@curtrans_no' must be defined."
Number=0
Source="MySql.Data"
StackTrace:
at MySql.Data.MySqlClient.Statement.SerializeParameter(MySqlParameterCollection parameters, MySqlStream stream, String parmName)
at MySql.Data.MySqlClient.Statement.InternalBindParameters(String sql, MySqlParameterCollection parameters, MySqlStream stream)
at MySql.Data.MySqlClient.Statement.BindParameters()
at MySql.Data.MySqlClient.PreparableStatement.Execute()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
InnerException:
*****
If there's any help you could give, it would be well appreciated.
Thanks!
-
Aug 6th, 2012, 02:32 PM
#2
Re: Fatal error encountered during command execution.
The error is "Message="Parameter '@curtrans_no' must be defined."
You need to show us your code for the CMDRepBillRep_Bill_Click event handler.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Aug 7th, 2012, 02:29 AM
#3
Thread Starter
New Member
Re: Fatal error encountered during command execution.
Hi,
Here's the code:
*****
cnn = New MySqlConnection("Database=" & ldbase & ";Data Source=" & lsource & ";User Id=" & luser & ";Password=" & lpwd)
Comm.Connection = cnn
Comm.CommandText = "select a.client_no, a.client_nm, b.matter, b.docket_no, " & _
"d.emp_code, e.expenses_type_no, f.expenses_type_nm, g.emp_fname, " & _
"g.emp_sname, h.position_name, e.tot_amt, g.emp_transpo, g.emp_prof_rate * d.hrs_wk tot_prof_rate, " & _
"d.hrs_wk, d.service_dt, d.service_desc, d.service_type_code, " & _
"d.trans_no serv_trans_no, e.trans_no exp_trans_no, " & _
"case " & _
"when d.service_type_code = 'AH' " & _
"THEN e.tot_amt " & _
"ELSE 0.0 " & _
"END appearance, " & _
"CASE " & _
"WHEN d.service_type_code <> 'AH' and e.expenses_type_no <> 'ET0001' " & _
"THEN e.tot_amt " & _
"ELSE 0.0 " & _
"END out_of_pocket, " & _
"d.location_cd, i.location_cd, " & _
"CASE " & _
"WHEN e.expenses_type_no = 'ET0001' " & _
"THEN i.tariff_emprate " & _
"ELSE 0.00 " & _
"END tariff_emprate, " & _
"CASE " & _
"WHEN e.expenses_type_no = 'ET0001' " & _
"THEN i.tariff_clientrate " & _
"ELSE 0.00 " & _
"END tariff_clientrate, " & _
"CASE e.serv_trans_no " & _
"WHEN " & _
"CASE e.serv_trans_no " & _
"WHEN @curtrans_no " & _
"THEN NULL " & _
"ELSE @curtrans_no := e.serv_trans_no " & _
"END " & _
"THEN g.emp_prof_rate * d.hrs_wk " & _
"ELSE 0.00 " & _
"END AS professional_fee " & _
"from clients_tbl a inner join " & _
"dockets_tbl b on a.client_no = b.client_no inner join " & _
"matter_tbl c on b.matter_cd = c.matter_cd inner join " & _
"services_tbl d on b.docket_no = d.docket_no left outer join " & _
"expenses_tbl e on d.docket_no = e.docket_no and d.emp_code = e.emp_code " & _
"and d.trans_no = e.serv_trans_no and d.service_type_code = e.service_type_code left outer join " & _
"expenses_type_tbl f on e.expenses_type_no = f.expenses_type_no " & _
"left outer join employees_tbl g on d.emp_code = g.emp_code " & _
"left outer join positions_tbl h on g.emp_position_code = h.position_code " & _
"left outer join locations_tbl i on d.location_cd = i.location_cd " & _
"where b.docket_no >= '" & cmbRepDockFrom.Text & "' and b.docket_no <= '" & cmbRepDockFrom.Text & "' and d.service_billable = 1 and e.expense_billable = 1 " & _
"and d.service_dt >= '" & CStr(DTPReports_Start.Value.Year) & "-" & _
CStr(DTPReports_Start.Value.Month) & "-" & _
CStr(DTPReports_Start.Value.Day) & "' " & _
"and d.service_dt <= '" & CStr(DTPReports_End.Value.Year) & "-" & _
CStr(DTPReports_End.Value.Month) & "-" & _
CStr(DTPReports_End.Value.Day) & "' " & _
"or b.docket_no >= '" & cmbRepDockFrom.Text & "' and b.docket_no <= '" & cmbRepDockFrom.Text & "' and d.service_billable = 1 and e.expense_billable is null " & _
"and d.service_dt >= '" & CStr(DTPReports_Start.Value.Year) & "-" & _
CStr(DTPReports_Start.Value.Month) & "-" & _
CStr(DTPReports_Start.Value.Day) & "' " & _
"and d.service_dt <= '" & CStr(DTPReports_End.Value.Year) & "-" & _
CStr(DTPReports_End.Value.Month) & "-" & _
CStr(DTPReports_End.Value.Day) & "';"
cnn.Open()
Dim da As New MySqlDataAdapter(Comm.CommandText, cnn)
Dim ds As LibrojoDS = New LibrojoDS
DReader = Comm.ExecuteReader
*****
I'm encountering the error when the "DReader = Comm.ExecuteReader" is executed.
-
Aug 7th, 2012, 09:44 AM
#4
Re: Fatal error encountered during command execution.
That is one hell of a query. I see that you do use the parameter @curtrans_no in your query. Is that a typo when the "@" shouldn't been there? If not, then you need to supply a value for that parameter by adding a parameter to your MySqlDataAdapter.Parameters collection and assign a value for it.
My suggestion: rewrite your query so that it's easier to read. Use parameters instead of string concatenations.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Aug 11th, 2012, 04:26 AM
#5
Thread Starter
New Member
Re: Fatal error encountered during command execution.
stanav
Thanks for this I'll try that.
 Originally Posted by stanav
That is one hell of a query. I see that you do use the parameter @curtrans_no in your query. Is that a typo when the "@" shouldn't been there? If not, then you need to supply a value for that parameter by adding a parameter to your MySqlDataAdapter.Parameters collection and assign a value for it.
My suggestion: rewrite your query so that it's easier to read. Use parameters instead of string concatenations.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|