Update an SQL Table from a DataGrid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kpetree
    New Member
    • Jan 2009
    • 2

    Update an SQL Table from a DataGrid

    Hello Everyone!

    I am trying to update a table on my SQL server from a program with a Data Grid. My project has the Datagrid setup with the columns that I need and it shows all the data and I can edit it I just need to know how to code a button that when pressed will update the data in the table.

    Thanks!
  • lotus18
    Contributor
    • Nov 2007
    • 865

    #2
    You can use an Update query : )



    Rey Sean

    Comment

    • kpetree
      New Member
      • Jan 2009
      • 2

      #3
      Ok... how do I go about doing that? Just for reference here is the code I'm using.


      Public Class Form1

      Private Sub ItemsBindingNav igatorSaveItem_ Click(ByVal sender As System.Object, ByVal e As System.EventArg s)
      Me.Validate()
      Me.ItemsBinding Source.EndEdit( )
      Me.TableAdapter Manager.UpdateA ll(Me._075DataS et)

      End Sub

      Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
      'TODO: This line of code loads data into the '_075DataSet1.i mitmidx_sql' table. You can move, or remove it, as needed.
      Me.Imitmidx_sql TableAdapter.Fi ll(Me._075DataS et1.imitmidx_sq l)
      'TODO: This line of code loads data into the '_075DataSet.It ems' table. You can move, or remove it, as needed.
      Me.ItemsTableAd apter.Fill(Me._ 075DataSet.Item s)

      End Sub

      Private Sub DataGridView1_C ellContentClick (ByVal sender As System.Object, ByVal e As System.Windows. Forms.DataGridV iewCellEventArg s) Handles DataGrid1.CellC ontentClick

      End Sub

      Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Post_Button.Cli ck
      If MsgBox("Are you sure you wish to upload these changes?", vbYesNo) = vbYes Then
      'This is the post button, this is what I need the code for' Else

      End If
      End Sub

      Private Sub Button1_Click_1 (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles Exit_Button.Cli ck
      If MsgBox("Are you sure you wish to quit?", vbYesNo) = vbYes Then
      Me.Close()


      Else

      End If
      End Sub

      Private Sub AboutQuoteField ChangeNAtorTool StripMenuItem_C lick(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles AboutQuoteField ChangeNAtorTool StripMenuItem.C lick
      AboutBox1.Show( )

      End Sub
      End Class

      Comment

      Working...