Simple question about insert a record.

  • Thread starter Miguel Dias Moura
  • Start date
M

Miguel Dias Moura

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
 
A

Ashish M Bhonkiya

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top