Simple question about insert a record.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Miguel Dias Moura

    Simple question about insert a record.

    Hello,

    i am working in an ASP.net / VB web site.
    I have a form.

    Does anyone knows a script to insert the form values in an Access Database?

    I was looking and looking and i couldn't find anything.

    Thank You,
    Miguel


  • srini

    #2
    RE: Simple question about insert a record.

    hi
    this is a simple example of inserting into MS Access. Hope it help

    the bes
    srini

    Comment

    • Ashish M Bhonkiya

      #3
      Re: Simple question about insert a record.

      Hi Miguel Dias Moura,
      here is the script.

      Try
      DBConnection = New OleDbConnection ( _
      "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
      "Data Source=d:\eComm erce\Databases\ eCommerce.mdb")
      DBConnection.Op en()
      SQLString = "INSERT INTO Products " & _
      "(ItemNumbe r, ItemType, ItemSupplier, ItemName, " & _
      "ItemDescriptio n, ItemPrice, ItemQuantity) " & _
      "VALUES (" & _
      "'" & ItemNumber.Text & "', " & _
      "'" & ItemType.Select edItem.Value & "', " & _
      "'" & Replace(ItemSup plier.Text, "'", "''") & "', " & _
      "'" & Replace(ItemNam e.Text, "'", "''") & "', " & _
      "'" & Replace(ItemDes cription.Text, "'", "''") & "', " & _
      ItemPrice.Text & ", " & _
      ItemQuantity.Te xt & _
      ")"
      DBCommand = New OleDbCommand(SQ LString, DBConnection)
      DBCommand.Execu teNonQuery
      DBConnection.Cl ose()
      AddMessage.Text = "Record added"
      Catch
      AddMessage.Text = "Update problem. Record not added. " & SQLString
      End Try

      HTH
      Regards
      Ashish M Bhonkiya


      "Miguel Dias Moura" <web001@27NOSPA Mlamps.com> wrote in message
      news:OFRITunSEH A.2128@TK2MSFTN GP11.phx.gbl...[color=blue]
      > Hello,
      >
      > i am working in an ASP.net / VB web site.
      > I have a form.
      >
      > Does anyone knows a script to insert the form values in an Access[/color]
      Database?[color=blue]
      >
      > I was looking and looking and i couldn't find anything.
      >
      > Thank You,
      > Miguel
      >
      >[/color]


      Comment

      Working...