jacobfscott
New member
- Joined
- Jan 29, 2010
- Messages
- 2
- Programming Experience
- Beginner
I am working on a simple application. I am opening a dialog from a menu that populates a datagridview with data from a dataset. I am using Visual Studio and and .mdf file. I have set the .xsd file with the default stuff (ie, I dragged the database from the server explorer to the .xsd file. Anyway, I have a button that is enabled when I click on one of the rows of the datagridview. When clicked, I am firing a SQL command to delete the selected row. The SQL works. I am unable to refresh the data. I will include the code. It is simple. My issue is that I cannot quite figure out why I cannot get the data in the dataset to change unless I actually close and reopen the application. I know this is about the table adapter. I have tried different variations of the update,clear and other methods. Most of my programming experience is with ASP and VB code behind.
Thanks for any help.
VB.NET:
Dim qSQL As String
Dim sqlcmd As New SqlCommand
qSQL = "DELETE FROM LocationMaster WHERE LocationID=" & DataGridView1.CurrentRow.Cells(0).Value
oConn.Open()
sqlcmd.CommandText = qSQL
sqlcmd.CommandType = CommandType.Text
sqlcmd.Connection = oConn
sqlcmd.ExecuteNonQuery()
oConn.Close()
lbl_delete.Visible = True
lbl_delete.Text = "Deleting Location: " & DataGridView1.CurrentRow.Cells(1).Value
Me.InventoryMainDataSet.LocationMaster.Clear()
Me.LocationMasterTableAdapter.Fill(Me.InventoryMainDataSet.LocationMaster)
Me.DataGridView1.DataSource = Nothing
Me.DataGridView1.DataSource = Me.InventoryMainDataSet.LocationMaster
Thanks for any help.