Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Save Changes to Datagridview

Posted on 2009-05-18
6
Medium Priority
?
826 Views
Last Modified: 2013-11-08
I am trying to save any changes to a datagridview control to a Microsoft Access database.  I am using the code show below to populate and set the update commands for the datatable.

Dim sSQL As String = "SELECT RecordNumber, LineNum, RecID, Pcs, Wgt FROM tblItems WHERE RecID = '" & sCrit & "' ORDER BY LineNum"

            Dim cn As New OleDbConnection(Global_Values.System_Database)
            daLineItems = New OleDbDataAdapter(sSQL, cn)
            dsLineItems = New DataSet
            dtLineItems = New DataTable

            If cn.State = ConnectionState.Closed Then
                cn.Open()
            End If

            'Insert Command
            Dim cmdInsert As New OleDbCommand("INSERT INTO tblItems (LineNum, RecID, Pcs, Wgt) VALUES (@LineNum, @RecID, @Pcs, @Wgt)", cn)
            daLineItems.InsertCommand = cmdInsert

            'Update Command
            Dim cmdUpdate As New OleDbCommand("UPDATE tblItems SET Line_Num = @LineNum, RecID = @RecID, Pcs = @Pcs, Wgt = @Wgt WHERE RecordNumber = @RecordNumber", cn)
            daItems.UpdateCommand = cmdUpdate

            daItems.Fill(dtLineItems)

            If dtItems.Rows.Count < 1 Then
                dtItems.Rows.Add()
            End If

            Me.DataGridView1.DataSource = dtItems
         

In the on-click event of a button i am using the following in an attempt save the changes back to the database:

          daItems.Update(dtItems)

When i click the save button I get the following error: No value given for one or more required parameters.

What am i doing wrong?

0
Comment
Question by:Mike_Stevens
  • 3
  • 2
6 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 24415414
0
 

Author Comment

by:Mike_Stevens
ID: 24415744
Tried that route and I concurrency issues
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24416033
Can you show what have you tried ?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Mike_Stevens
ID: 24422213
I resolved the problem....need to define the parameters for the insert and update commands
0
 
LVL 48

Accepted Solution

by:
jpaulino earned 2000 total points
ID: 24422260
I looked to that but you didn't needed if you use in other way.
It's working and that is the most important :)
0
 
LVL 3

Expert Comment

by:Fordraiders
ID: 33043725
mike stevens, could you post the solution, that you used...having same problem..
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question