Simple question about insert a record.

  • Thread starter Thread starter Miguel Dias Moura
  • Start date 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
 
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
 
Back
Top