Simple question about insert a record.

Discussion in 'ASP .Net' started by Miguel Dias Moura, Jun 4, 2004.

  1. 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
     
    Miguel Dias Moura, Jun 4, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?c3Jpbmk=?=, Jun 5, 2004
    #2
    1. Advertising

  3. Hi Miguel Dias Moura,
    here is the script.

    Try
    DBConnection = New OleDbConnection( _
    "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=d:\eCommerce\Databases\eCommerce.mdb")
    DBConnection.Open()
    SQLString = "INSERT INTO Products " & _
    "(ItemNumber, ItemType, ItemSupplier, ItemName, " & _
    "ItemDescription, ItemPrice, ItemQuantity) " & _
    "VALUES (" & _
    "'" & ItemNumber.Text & "', " & _
    "'" & ItemType.SelectedItem.Value & "', " & _
    "'" & Replace(ItemSupplier.Text, "'", "''") & "', " & _
    "'" & Replace(ItemName.Text, "'", "''") & "', " & _
    "'" & Replace(ItemDescription.Text, "'", "''") & "', " & _
    ItemPrice.Text & ", " & _
    ItemQuantity.Text & _
    ")"
    DBCommand = New OleDbCommand(SQLString, DBConnection)
    DBCommand.ExecuteNonQuery
    DBConnection.Close()
    AddMessage.Text = "Record added"
    Catch
    AddMessage.Text = "Update problem. Record not added. " & SQLString
    End Try

    HTH
    Regards
    Ashish M Bhonkiya


    "Miguel Dias Moura" <> wrote in message
    news:...
    > 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
    >
    >
     
    Ashish M Bhonkiya, Jun 5, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SnVzdGlu?=

    Retrieving Record Key while creating the record.

    =?Utf-8?B?SnVzdGlu?=, Oct 4, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    665
    =?Utf-8?B?SnVzdGlu?=
    Oct 5, 2004
  2. olafmol
    Replies:
    4
    Views:
    17,476
    Elton Wang
    Feb 22, 2005
  3. Bobby Edward

    EDM question - How insert record thru code?

    Bobby Edward, Sep 24, 2008, in forum: ASP .Net
    Replies:
    0
    Views:
    410
    Bobby Edward
    Sep 24, 2008
  4. Frits van Soldt

    How to insert a new record in detailsview when there are no record

    Frits van Soldt, Nov 16, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    835
    Frits van Soldt
    Nov 17, 2005
  5. Guest
    Replies:
    1
    Views:
    285
    Alex G
    Jan 9, 2004
Loading...

Share This Page