|
-
Nov 20th, 2003, 04:36 AM
#1
Thread Starter
Fanatic Member
SQL stmt produces Error 0
Hi
I have this SQl Stmt in one of my procedure but it produces an error 0 on execute...
Can anyone spot the obvious?
VB Code:
_strSql = " update tbl_scale_event SET " & _
" EVENT_DATETIME = '" & finalDateTime & "', " & _
" SCALE_NUMBER = '" & CInt(StrScaleNumber) & "', " & _
" EVENT_STATUS = '" & CStr(Event_Status) & "', " & _
" Operator_badge = '" & Strshift & Replace(strBadge, " '", "''") & "', " & _
" Operator_Lastname = '" & Replace(strLast_Name, "'", "''") & "' " & _
" MANUGACTURE_DATETIME = '" & (finalDateTime) & "'," & _
" WHERE " & _
" Scale_Event_ID = '" & (ObjRSprodidvalues.Fields(0).Value) & "'"
m_Intwndprogress = 30
'if accepted display users Input/executes and initiates a scale transaction
objOcn.Execute l_strSql 'execute SQL statement
Thanks
Last edited by holly; Nov 20th, 2003 at 04:45 AM.
** HOLLY ** 
-
Nov 20th, 2003, 05:02 AM
#2
yes I can spot the obvious - error 0 means no error!
-
Nov 20th, 2003, 05:04 AM
#3
oooh.. just spotted the commas (and lack of) at the end of each line. here's at least part of it:
VB Code:
" Operator_Lastname = '" & Replace(strLast_Name, "'", "''") & "', " & _
" MANUGACTURE_DATETIME = '" & (finalDateTime) & "' " & _
" WHERE " & _
-
Nov 20th, 2003, 05:18 AM
#4
Thread Starter
Fanatic Member
Si_the_geek, I have change my sql and I still receive the error
0......the sql stmt is as follows
VB Code:
l_strSql = " update tbl_scale_event SET " & _
" EVENT_DATETIME = '" & finalDateTime & "', " & _
" SCALE_NUMBER = '" & CInt(StrScaleNumber) & "', " & _
" EVENT_STATUS = '" & CStr(Event_Status) & "', " & _
" Operator_badge = '" & Strshift & Replace(strBadge, "'", "''") & "', " & _
" Operator_Lastname = '" & Replace(strLast_Name, "'", "''") & "', " & _
" MANUFACTURE_DATETIME = '" & finalDateTime & "'" & _
" WHERE " & _
" Scale_Event_ID = '" & (ObjRSprodidvalues.Fields(0).Value) & "'"
Debug.Print l_strSql
m_Intwndprogress = 30
'if accepted display users Input/executes and initiates a scale transaction
objOcn.Execute l_strSql 'execute SQL statement
Thanks
If the error 0 means - no error why do I get a msgbox error...
Thanks
** HOLLY ** 
-
Nov 20th, 2003, 05:32 AM
#5
-
Nov 20th, 2003, 05:43 AM
#6
Thread Starter
Fanatic Member
Hi si_the_geek this is my full procedure
is my code that bad?? Maybe there is something
wrong in the code......the error I receive is 'error 0 in procedure Validate_product_code...
Thanks for your help!!
VB Code:
Private Sub validate_product_code(ByVal strBadge As String, ByVal strLast_Name As String, ByVal mfgDate As String, ByVal Strshift As String)
'Declare Variables
Dim l_strSql As String
Dim tmpTime As Date
Dim tmpDate As Date
Dim tmpDateTime As String
Dim finalDateTime As Date
Dim StrProductLine As String
Dim ObjProdCmd As ADODB.Command
Const Event_Status = "PRODWD"
'format time and date
On Error GoTo validate_product_code_Error
Set ObjProdCmd = New ADODB.Command 'Create new command instance
With ObjProdCmd
.ActiveConnection = objOcn 'set active connection
.CommandType = adCmdStoredProc
.CommandText = "SP_Product_ID" 'Stored Proc
.Parameters.Append .CreateParameter("@ProductID", adVarChar, adParamInput, 10, txtinformation.Text)
End With
Set ObjRSprodidvalues = ObjProdCmd.Execute 'execute SP
'executes SP to validate product
ObjRSprodidvalues.Fields.Refresh 'refresh RS fields
If (ObjRSprodidvalues.BOF) = True Then
DoEvents
Load frmvoidopid
frmvoidopid.Show vbModal
Exit Sub:
Else
ObjRSprodidvalues.MoveLast 'move to last RS
End If
ObjRSprodidvalues.Fields.Refresh 'refresh RS fields
lblScaleEventID = ObjRSprodidvalues.Fields(0).Value
l_strSql = " update tbl_scale_event SET " & _
" EVENT_DATETIME = '" & finalDateTime & "', " & _
" SCALE_NUMBER = '" & CInt(StrScaleNumber) & "', " & _
" EVENT_STATUS = '" & CStr(Event_Status) & "', " & _
" Operator_badge = '" & Strshift & Replace(strBadge, "'", "''") & "', " & _
" Operator_Lastname = '" & Replace(strLast_Name, "'", "''") & "', " & _
" MANUFACTURE_DATETIME = '" & finalDateTime & "'" & _
" WHERE " & _
" Scale_Event_ID = '" & (ObjRSprodidvalues.Fields(0).Value) & "'"
Debug.Print l_strSql
m_Intwndprogress = 30
'if accepted display users Input/executes and initiates a scale transaction
objOcn.Execute l_strSql 'execute SQL statement
ObjRSprodidvalues.Fields.Refresh 'refresh the database
lblTendigitCode = "Product Code" + vbCrLf + "FW" +
check_Product_Line (StrProductLine) 'Procedure to check the relevant product - line
m_Intwndprogress = 35
Exit Sub
validate_product_code_Error:
Call ModError_log 'All error descriptions written to a error log
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure validate_product_code of Form frmscan"
End Sub
Last edited by holly; Nov 20th, 2003 at 06:40 AM.
** HOLLY ** 
-
Nov 20th, 2003, 05:58 AM
#7
Originally posted by holly
is my code that bad??
only the error handling!
the rest seems ok, apart from the indenting (which is probably fine on your pc)
Number 1 in my last post is not the issue (your "exit sub" does the job). The trouble is the sub "ModError_log" - somewhere in here the error is reset.
You can either show the message before you call the sub, or fix the sub.
I'm guessing that this sub is used in several projects, so you should try to fix that. Alternatively create a new sub which showns the error and does the logging, eg:
VB Code:
Sub ShowError (SubName as String)
Dim ErrMessage as String 'Store the message
ErrMessage = "Error " & Err.Number & " (" & Err.Description & ")" & vbCr _
& "in procedure: " & SubName
Call ModError_log 'Log the error
Msgbox ErrMessage 'Show the message
End Sub
'in your "validate_product_code" sub:
...
validate_product_code_Error:
Call ShowError ("validate_product_code of Form frmscan")
...
-
Nov 20th, 2003, 06:08 AM
#8
Thread Starter
Fanatic Member
-
Nov 20th, 2003, 06:21 AM
#9
no worries.. good luck
-
Nov 22nd, 2003, 03:25 AM
#10
holly
You know, it's very simple thing to do and almost no one does it. Put a debug print immediately after you create the SQL statement. You might be amazed how quickly you can spot simple problems.
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
|