Current Recordset does not support updating 
Author Message
 Current Recordset does not support updating

Hi

  I'm using VB6 and I want to add a record in my MDB file but when I trigger
 the AddNew method in the recordset object "RS.Addnew" it give me this error

Current Recordset does not support updating

I have no problem to get the data but I can't update

Here is part of the code

=====================

AccessConnectTemplate = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
                       "DBQ=" & Frm_CallsLog.TemplateMDB & ";" & _
                       "DefaultDir=" & Frm_CallsLog.TemplateDir & ";" & _
                       "Mode=Read|Write;" & _
                       "UID=admin;PWD=;"

====================

Dim Conn1 As ADODB.Connection
   Dim Cmd1 As ADODB.Command
   Dim Params1 As ADODB.Parameters
   Dim Param1 As ADODB.Parameter
   Dim Rs1 As ADODB.Recordset
   Dim FieldName As String, FieldID As Long, FieldFileName As String

   Dim I As Integer

   If AccessConnectTemplate = "" Then
        MsgBox ("Could not find the Template MDB file")
   End If

   On Error GoTo VbError

   Set Conn1 = New ADODB.Connection

   On Error GoTo AdoError

   Conn1.ConnectionString = AccessConnectTemplate
   Conn1.Open

   Set Cmd1 = New ADODB.Command
   Cmd1.ActiveConnection = Conn1
   Cmd1.CommandText = "SELECT * FROM Template WHERE ID"

   Set Param1 = Cmd1.CreateParameter(, adInteger, adParamInput, 3)
   Param1.Value = 10
   Cmd1.Parameters.Append Param1
   Set Param1 = Nothing

   Set Rs1 = Cmd1.Execute()
   Rs1.AddNew

   ActualTemplateIndex = Rs1.Fields("ID")
   ActualTemplateName = txt_InfoB_TemplateName
   ActualTemplateFileName = txt_InfoB_FileName

   Rs1.Fields("Name") = ActualTemplateName
   Rs1.Fields("File") = ActualTemplateFileName
   ReDim Preserve TemplateList(UBound(TemplateList) + 1)
   With TemplateList(I)
       .ID = ActualTemplateIndex
       .TemplateName = ActualTemplateName
       .TemplateFileName = ActualTemplateFileName
   End With
   cmb_InfoB_TemplateName.AddItem ActualTemplateName

   Rs1.Update

   Rs1.MoveLast

   Rs1.Close
   Conn1.Close
   On Error Resume Next
   Set Rs1 = Nothing
   Set Conn1 = Nothing
   Exit Sub
AdoError:
VbError:
       strTmp = strTmp & vbCrLf & "VB Error # " & Str(Err.Number)
       strTmp = strTmp & vbCrLf & "   Generated by " & Err.Source
       strTmp = strTmp & vbCrLf & "   Description  " & Err.Description

       MsgBox strTmp & "   : I = " & I



Tue, 14 Jun 2005 15:14:52 GMT  
 Current Recordset does not support updating


Quote:
> Dim Conn1 As ADODB.Connection
>    Dim Cmd1 As ADODB.Command
* * *
>    Cmd1.ActiveConnection = Conn1
>    Cmd1.CommandText = "SELECT * FROM Template WHERE ID"
* * *
>    Set Rs1 = Cmd1.Execute()
>    Rs1.AddNew
> Current Recordset does not support updating

Indeed it does not.  Try opening it just by opening the Recordset instead of
selecting records out of it, i.e.

DSN = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
      "DBQ=" & Frm_CallsLog.TemplateMDB & ";" & _
      "DefaultDir=" & Frm_CallsLog.TemplateDir & ";" & _
      "Mode=Read|Write;" & _
      "UID=admin;PWD=;"

Dim RS1 as ADODB.Recordset
Dim Conn1 As ADODB.Connection
Conn1.Open(DSN)
RS1.Open("[Template]", Conn1, 1, 3)

Then RS1.AddNew should be peachy.

I would take a look at the O'Reilly ADO book and read up on the distinction
between Connection, Command, and Recordset as it can be fuzzy at times.

-doug



Tue, 14 Jun 2005 17:27:45 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Current RecordSet does not support updating Oracle 8

2. Current RecordSet does not support updating Oracle 8

3. Current Recordset does not support updating

4. Current Recordset does not support bookmarks

5. Help: Current Recordset does not support bookmarks...

6. Current provider does not support returning multiple recordsets from a single execution

7. Help: updating text file-Updating Data in a linked table not supported by this ISAM

8. 3251 Current provider doesn't support returning multiple recordsets from a single execution

9. ADODB.Recordset.Update does not update?

10. Bound controls not updating ADO with adodc.recordset.update command

11. Updating textbox via code not updating recordset

12. ADO Update the Database with the modify done on a disconnected recordset in background mode

 

 
Powered by phpBB® Forum Software