I'm trying to use VB.NET to insert the data in the current row of my datagrid into a table. I wrote the following code:
Dim vCustomer, vBulkQty, vItem, vBaseUnit, vEachQty, vEachUnit As String vCustomer = dgCustomers.CurrentRow.Cells(0).Value vItem = dgItems.CurrentRow.Cells(0).Value vBulkQty = dgItems.CurrentRow.Cells(3).Value vBaseUnit = dgItems.CurrentRow.Cells(4).Value vEachQty = dgItems.CurrentRow.Cells(5).Value vEachUnit = dgItems.CurrentRow.Cells(6).Value Dim Insert As String Insert = "INSERT INTO OTM_ORDERS(CustomerID,ItemNo,BulkQty,BaseUnit,EachQty,StockUnit) " _ & "VALUES ('" & Trim(vCustomer) & "','" & Trim(vItem) & "','" & Trim(vBulkQty) & "','" _ & Trim(vBaseUnit) & "','" & Trim(vEachQty) & "','" & Trim(vEachUnit) & "')" Dim sqlCom As New SqlCommand(Insert, conn) sqlCom.ExecuteNonQuery()
The problem is that although there doesn't seem to be anything wrong with the code I get an unhandled SQLException on the sqlCom.ExecuteNonQuery() statement that says "Invalid object name 'OTM_ORDERS'."
I've already created this table using SQL, so why am I not able to insert data into it?