Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27412

I need a vb.net INSERT example to an Access 2007 table example.

$
0
0
I have a vb.net windows form program that needs to insert new rows into an Access table. It's many years since I have worked with Access. I'm getting syntax errors on my Insert statement. If I remember correctly, it seems that the SQL is slightly different for Access than it is for SQL which I normally use. Here is my SQL statement:

Code:

Dim queryString As String = "INSERT INTO [ShippingLabel] (Order ID, Order Date, Ship To Name, Ship To Add 1, Ship To Add 2, Ship To City, Ship To State, Ship To Zip, Ship To Country, Email, Phone, AES, PO#, Ship Method, FedEx Shipping Code, Total Qty, Total value, Unit Price, FedEx Acct Number, Schedule B Number, Schedule B Description, FedEx Packaging Code) Values(" & iID & ", " & _
                                                                                          OrderDate & ", " & _
                                                                                          CStr(ShipToName) & ", " & _
                                                                                          CStr(ShipToAdd1) & ", " & _
                                                                                          CStr(ShipToAdd2) & ", " & _
                                                                                          CStr(dgvOrder.Rows(band.Index).Cells(5).Value).ToString.TrimEnd().Replace(",", " ") & ", " & _
                                                                                          CStr(dgvOrder.Rows(band.Index).Cells(6).Value).ToString.TrimEnd().Replace(",", " ") & ", " & _
                                                                                          CStr(dgvOrder.Rows(band.Index).Cells(7).Value).ToString.TrimEnd().Replace(",", " ") & ", " & _
                                                                                          CStr(ShipToCountry) & ", " & _
                                                                                          Email & ", " & _
                                                                                          Phone & ", " & _
                                                                                          AESNumber & ", " & _
                                                                                          CustomValuesXml & ", " & _
                                                                                          ShippingMethod & ", " & _
                                                                                          FedExShippingCode & ", " & _
                                                                                          iTotalQty & ", " & _
                                                                                          FormatNumber(sngExtendedAmount.ToString, 2) & ", " & _
                                                                                          FormatNumber(sngPrice.ToString, 2) & ", " & _
                                                                                          "" & ", " & _
                                                                                          "" & ", " & _
                                                                                          "" & ", " & _
                                                                                          "" & ", " & _
                                                                                          ")"

Do I need single quotes around my values perhaps? Does anyone have an example I could look at?

Viewing all articles
Browse latest Browse all 27412

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>