I am using a data grid view to display information from a database and I can't get it to update correctly. I can see the data from the database but when I change information and save it it changes the entire column's information. My rows need to have different values in the same column so this is a problem.
-Here is my code so far, what the program does is makes a list of transactions that are entered.
Public Class Form1
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
If MsgBox("Add new transaction?", MsgBoxStyle.YesNo, " ") <> 7 Then
If IsNumeric(in_cost.Text) Then
Dim x As Int16 = Database1DataSet.Table1.Count + 1 '//gets # value
Me.Table1TableAdapter.Insert(Format(Now, "dddd, M/dd/yy"), x, in_cost.Text, in_prod.Text, in_type.Text, in_note.Text, 9999.99) '//Writes new index to DB table
Me.Table1TableAdapter.Fill(Me.Database1DataSet.Table1)
Else
MsgBox("Cost is non-numeric!")
End If
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Table1TableAdapter.Fill(Me.Database1DataSet.Table1)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Table1TableAdapter.Fill(Me.Database1DataSet.Table1)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Table1TableAdapter.Update(Me.Database1DataSet.Table1)
End Sub
End Class
-SQL UPDATE command:
UPDATE Table1
SET Balance = @p1, Note = @p2, Type = @p3, Product = @p4, Cost = @p5, # = @p6, Date = @p7
Thanks in advance for any help.