Help for Update a Recordset

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Manojthanal
    New Member
    • Aug 2007
    • 5

    Help for Update a Recordset

    I am doing a project with VB6 and Access
    usin DSN Method.
    But I cant run the edit command
    When clicking on Update Button then
    Run time Error is Comming

    i.e.

    Run-time error- '2147217900 (80040e14)':
    [Microsoft][ODBC Microsoft access Driver] Extra) in queryexpression "a')


    The code i used in project is given below

    Private Sub CMDAddNew_Click ()
    If CMDAddNew.Capti on = "&Save" Then
    CNN.Execute "INSERT INTO TB_Details Values ('" & TXTRegNo & "','" & TXTName & "'," & _
    "'" & TXTAddress & "','" & CMBDistrict & "','" & TXTDesignation & "'," & _
    "'" & TXTSubject & "', '" & TXTQualificatio n & "','" & TXTExperience & "','" & TXTRemarks & "')"
    MsgBox "Data saved Successfully", vbInformation, "Save"
    Clearall
    Frame1.Enabled = False
    CMDAddNew.Capti on = "Add &New"
    Else
    If CMDAddNew.Capti on = "&Update" Then
    CNN.Execute "UPDATE TB_Details SET RegNo = '" & TXTRegNo & "', Name = '" & TXTName & "'," & _
    "Address = '" & TXTAddress & "', District = '" & CMBDistrict & "',Designat ion = '" & TXTDesignation & "'," & _
    "Subject = '" & TXTSubject & "', Qualifications = '" & TXTQualificatio n & "', Experience = '" & TXTExperience & "', Remarks = '" & TXTRemarks & "')" & _
    "WHERE RegNo = '" & TXTRegNo & "'"
    MsgBox "Data Updated Successfully", vbInformation, "Save"
    CMDAddNew.Capti on = "Add &New"
    End If
    'Else
    'Frame1.Enabled = True
    ' CMDAddNew.Capti on = "&Save"
    ' TXTRegNo.SetFoc us
    End If
    End Sub

    Pls Help for correcting the project

    With regards

    Manoj thanal
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    simply try this format for any DML operation.
    [code=vb]
    conn.BeginTrans ' conn is the ADODB connection object.
    conn.Execute "your sql statment here"
    conn.CommitTran s
    [/code]

    Comment

    Working...