Good day experts, i'm trying to run a program to populate my datagridview wherein i can edit,delete or add a new row. i have my code here but something is not right i think. when i try to add a new row, only column0 which is my ID set as s primary key and my column1 for my itemName, are added,the next column are not updated which is itemPrice. please see my code.any help is appreciated
Dim da As SqlDataAdapter
Dim cmd As SqlCommand
Dim ds As New DataSet
''this how i populate my datagrid
Dim con As New SqlConnection(ConnectString())
con.Open()
cmd = New SqlCommand("SELECT Id,MiscName as [Miscellaneous Name],convert(decimal(10,2),MiscPrice) as [Price] FROM Miscellaneous", con)
da = New SqlDataAdapter(cmd)
da.Fill(ds, "Miscellaneous")
con.Close()
dgvMiscList.DataSource = ds
dgvMiscList.DataMember = "Miscellaneous"
''button to enable adding new rows
dgvMiscList.ReadOnly = False
btnSaveNewMisc.Enabled = True
btnAddNewMisc.Enabled = False
''and this is how i update the database
Dim cmdbuilder As New SqlCommandBuilder(da)
Dim i As Integer
Try
i = da.Update(ds, "Miscellaneous")
MsgBox("Records Updated= " & i)
Catch ex As Exception
MsgBox(ex.Message)
End Try