-
Oct 4th, 2007, 01:35 AM
#1
Thread Starter
Addicted Member
runtime error 13 on update...
i got the function below to execute an update command (access db), i got a runtime error 13 when i call the function but the the update is running in the database....any help why i got the error...
Code:
Public Function ExecuteSQLa(ByVal strSql As String, Optional ByRef RowsAffected As Long) As ADODB.Recordset
Dim cmd As ADODB.Command
lngRowsAffected = 0
On Error Resume Next 'GoTo ExecuteSQLa_Error
Set cmd = New ADODB.Command
cmd.ActiveConnection = AccCon
cmd.CommandText = strSql
Set ExecuteSQLa = cmd.Execute(RowsAffected)
lngRowsAffected = RowsAffected
Set cmd = Nothing
On Error GoTo 0
Exit Function
ExecuteSQLa_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ExecuteSQLa of Module modMain"
End Function
-
Oct 4th, 2007, 01:37 AM
#2
Re: runtime error 13 on update...
Can you point out on which line this error occurs
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Oct 4th, 2007, 01:40 AM
#3
Thread Starter
Addicted Member
Re: runtime error 13 on update...
when i set the command
Code:
Set cmdCust = DBa.ExecuteSQLa(sqlCust)
-
Oct 4th, 2007, 01:48 AM
#4
Re: runtime error 13 on update...
can you just try removing the resume next statement and make it as
vb Code:
On Error GoTo ExecuteSQLa_Error
and then tell us which line it gives error
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Oct 4th, 2007, 02:07 AM
#5
Thread Starter
Addicted Member
Re: runtime error 13 on update...
i did it ..same error same line,trying to debug it, pressing F8 from the set command line i got the runtime error on the Exit Function line (??)
-
Oct 4th, 2007, 03:45 AM
#6
Frenzied Member
Re: runtime error 13 on update...
-
Oct 4th, 2007, 03:48 AM
#7
Thread Starter
Addicted Member
Re: runtime error 13 on update...
disables error handling in the current procedure
-
Oct 4th, 2007, 03:55 AM
#8
Frenzied Member
Re: runtime error 13 on update...
if that is the case then what is the use of having First you use then ????
-
Oct 4th, 2007, 03:59 AM
#9
Thread Starter
Addicted Member
Re: runtime error 13 on update...
these are sample code lines trying to debug the error, without any of these lines i got the same runtime error...
-
Oct 4th, 2007, 04:34 AM
#10
Frenzied Member
Re: runtime error 13 on update...
you haven't dimmed as you know error 13 is usually associated with datatype mismatch
-
Oct 4th, 2007, 04:41 AM
#11
Frenzied Member
Re: runtime error 13 on update...
I tried to duplicate what you might be doing. I didnot receive any error! Am I doing what you are doing??
vb Code:
Dim cmd As ADODB.Command
Dim conn As Connection
Private Sub Command1_Click()
Dim cmdCust As ADODB.Recordset
Set cmdCust = ExecuteSQLa("Select * from BooksMaster")
MsgBox cmdCust.Fields(0)
End Sub
Private Function ExecuteSQLa(ByVal strSQL As String, Optional ByRef RowsAffected As Long) As ADODB.Recordset
'Dimmed lngRowsAffected
Dim lngRowsAffected As Long
lngRowsAffected = 0
Set cmd = New ADODB.Command
cmd.ActiveConnection = conn
cmd.CommandText = strSQL
'Added this line
cmd.CommandType = adCmdText
Set ExecuteSQLa = cmd.Execute(RowsAffected)
lngRowsAffected = RowsAffected
Set cmd = Nothing
Exit Function
End Function
Private Sub Form_Load()
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source = E:\My Documents\Projects\Books Maintenance\Database\books1.mdb"
conn.Open
End Sub
-
Oct 4th, 2007, 06:39 AM
#12
Thread Starter
Addicted Member
Re: runtime error 13 on update...
yes, its almost the same....but i got still error...(i added the line you add)
-
Oct 5th, 2007, 01:28 AM
#13
Frenzied Member
Re: runtime error 13 on update...
-
Oct 5th, 2007, 01:34 AM
#14
Frenzied Member
Re: runtime error 13 on update...
pls also watch out for this
Dim cmdCust As ADODB.Recordset
Set cmdCust = ExecuteSQLa(myQuery)
is diff from yours
Set cmdCust = DBa.ExecuteSQLa(sqlCust)
what is DBa?
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
|