|
-
Aug 8th, 2012, 08:58 AM
#1
Thread Starter
Member
Issues updating access database from datagrid
Hello, I am just trying to pull information from my datagrid and save it as a new record in access but having a hard time. Any recommendations would be appreciated.
Code:
Try
For i = 0 To WelcomeForm.CallerDataGridView.RowCount - 1
If CDbl(WelcomeForm.CallerDataGridView.Rows(i).Cells("Id").Value.ToString) = _ID Then
Using dnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\CallerLists\" + CallerTextBox.Text + ".mdb")
Using dmd As New OleDbCommand("INSERT INTO Completed (Call Type, Dealer Number, District, Supervision Group, Service or Tire, Store Number, Associate, City, State, Phone, Vehicle, Tire Size, Notes ) VALUES (@Call Type, @Dealer Number, @District, @Supervision Group, @Service or Tire, @Store Number, @Associate, @City, @State, @Phone, @Vehicle, @Tire Size, @Notes)", dnn)
dmd.Parameters.AddWithValue("@Call Type", WelcomeForm.CallerDataGridView.Rows(i).Cells("Call Type").Value.ToString)
dmd.Parameters.AddWithValue("@Dealer Number", WelcomeForm.CallerDataGridView.Rows(i).Cells("Dealer Number").Value.ToString)
dmd.Parameters.AddWithValue("@District", WelcomeForm.CallerDataGridView.Rows(i).Cells("District").Value.ToString)
dmd.Parameters.AddWithValue("@Supervision Group", WelcomeForm.CallerDataGridView.Rows(i).Cells("Supervision Group").Value.ToString)
dmd.Parameters.AddWithValue("@Service or Tire", WelcomeForm.CallerDataGridView.Rows(i).Cells("Service or Tire").Value.ToString)
dmd.Parameters.AddWithValue("@Store Number", WelcomeForm.CallerDataGridView.Rows(i).Cells("Store Number").Value.ToString)
dmd.Parameters.AddWithValue("@Call #", WelcomeForm.CallerDataGridView.Rows(i).Cells("Call #").Value.ToString)
dmd.Parameters.AddWithValue("@Retailer Type", WelcomeForm.CallerDataGridView.Rows(i).Cells("Retailer Type").Value.ToString)
dmd.Parameters.AddWithValue("@Store Name", WelcomeForm.CallerDataGridView.Rows(i).Cells("Store Name").Value.ToString)
dmd.Parameters.AddWithValue("@Associate", WelcomeForm.CallerDataGridView.Rows(i).Cells("Associate").Value.ToString)
dmd.Parameters.AddWithValue("@City", WelcomeForm.CallerDataGridView.Rows(i).Cells("State").Value.ToString)
dmd.Parameters.AddWithValue("@State", WelcomeForm.CallerDataGridView.Rows(i).Cells("State").Value.ToString)
dmd.Parameters.AddWithValue("@Phone", WelcomeForm.CallerDataGridView.Rows(i).Cells("Phone").Value.ToString)
dmd.Parameters.AddWithValue("@Vehicle", WelcomeForm.CallerDataGridView.Rows(i).Cells("Vehicle").Value.ToString)
dmd.Parameters.AddWithValue("@Tire Size", WelcomeForm.CallerDataGridView.Rows(i).Cells("Tire Size").Value.ToString)
dmd.Parameters.AddWithValue("@Notes", WelcomeForm.CallerDataGridView.Rows(i).Cells("Notes").Value.ToString)
dnn.Open()
dmd.ExecuteNonQuery()
End Using
End Using
End If
Next
Catch ex As Exception
MsgBox(ex.ToString)
Exit Sub
End Try
Error I recieve is
System.Data.OleDb.OleDbException (0x80040E14): Syntax error in INSERT INTO statement.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at Mystery_Shopper_Pro.TireProsDealerForm.CompleteButton_Click(Object sender, EventArgs e) in C:\Users\Jbailey\documents\visual studio 2010\Projects\Mystery Shopper Pro\Mystery Shopper Pro\SurveyForms\TP\TirePros\TireProsDealerForm.vb:line 428
With this line being 428...
dmd.ExecuteNonQuery()
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|