updating a database through a visual basic form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • janita
    New Member
    • Jul 2008
    • 1

    updating a database through a visual basic form

    Hi
    i need to update a database which is connected to a form in visual basic.
    the entries that made in text boxes present in the form must be updated to the connected database.
    Can u help me with a sample code..

    thanks,
  • smartchap
    New Member
    • Dec 2007
    • 236

    #2
    Using ADO and its update method u can update the data written in textboxes or a grid etc in a form. For updating u can place a command button on form which is clicked after all fields / controls on the form are filled as required.

    Comment

    • oumaG
      New Member
      • Jul 2008
      • 1

      #3
      <QUOTE>
      Ms Access
      using ADO you can write the following code
      Public dbase As New ADODB.Connectio n
      Public rsconn As New ADODB.Recordset
      Set dbase = New ADODB.Connectio n
      dbase.Open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & App.Path & "\databaseName. mdb"
      Set rsconn = New ADODB.Recordset
      Set rsconn = dbase.Execute(" UPDATE tableName SET field1 = '" & txtfieldName.Te xt &"' WHERE keyField = '" & txtkeyField.Tex t & "'")

      With rsconn
      .CursorLocation = adUseClient
      .LockType = adLockOptimisti c
      .Source = "select * from ItableName "
      .ActiveConnecti on = dbase
      .Open

      End With


      Set rsconn = Nothing
      Set dbase = Nothing
      </QUOTE>

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        TRY USING THIS


        [code=vb]
        con.begintrans 'con is the ADODB connection object
        con.execute "your insert / update statement here"
        con.committrans

        [/code]

        Comment

        Working...