deanlee17
asked on
vb.net refresh dataset
Hi Experts,
I have the following code to setup to load a datagrid with data from a table in a dataset. In a seperate procedure I need to refresh the data in the table in the dataset (the table in the back end database will have been modified by this time). I just cant figure out how to do it?...
Thanks,
Dean...
Public Sub LoadLinesGrid()
Dim LinesConnString As String
Dim LinesConnConect As SqlConnection
Dim LinesConnAdapter As New SqlDataAdapter
Dim LinesSelectSql As String
Dim LinesSQDataset As New DataSet()
Dim MyIndex As Integer
LinesConnString = "Data Source=XXXXX"
LinesConnConect = New SqlConnection(LinesConnStr ing)
LinesSelectSql = "Select * FROM WPFtblSmartQuoteLines where LinesAstuteRef = '" & FlxHeader(MyIndex, 8).Text.ToString & "'"
Try
'Open connect to OMSytem
LinesConnConect.Open()
'Insert SQL Select COMMMAND above
LinesConnAdapter.SelectCom mand = New SqlCommand(LinesSelectSql, LinesConnConect)
'Run SQL Select Query
LinesConnAdapter.SelectCom mand.Execu teNonQuery ()
'Load Dataset with results..
LinesConnAdapter.Fill(Line sSQDataset )
'Set Dateset to load into DbGrdGRNInfo
FlxLine.ItemsSource = LinesSQDataset.Tables(0).D efaultView
'Clear SqlAdaptor
LinesConnAdapter.Dispose()
LinesSelectSql = Nothing
'Close Connection to OMSystem
LinesConnConect.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
I have the following code to setup to load a datagrid with data from a table in a dataset. In a seperate procedure I need to refresh the data in the table in the dataset (the table in the back end database will have been modified by this time). I just cant figure out how to do it?...
Thanks,
Dean...
Public Sub LoadLinesGrid()
Dim LinesConnString As String
Dim LinesConnConect As SqlConnection
Dim LinesConnAdapter As New SqlDataAdapter
Dim LinesSelectSql As String
Dim LinesSQDataset As New DataSet()
Dim MyIndex As Integer
LinesConnString = "Data Source=XXXXX"
LinesConnConect = New SqlConnection(LinesConnStr
LinesSelectSql = "Select * FROM WPFtblSmartQuoteLines where LinesAstuteRef = '" & FlxHeader(MyIndex, 8).Text.ToString & "'"
Try
'Open connect to OMSytem
LinesConnConect.Open()
'Insert SQL Select COMMMAND above
LinesConnAdapter.SelectCom
'Run SQL Select Query
LinesConnAdapter.SelectCom
'Load Dataset with results..
LinesConnAdapter.Fill(Line
'Set Dateset to load into DbGrdGRNInfo
FlxLine.ItemsSource = LinesSQDataset.Tables(0).D
'Clear SqlAdaptor
LinesConnAdapter.Dispose()
LinesSelectSql = Nothing
'Close Connection to OMSystem
LinesConnConect.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Refreshing is reloading so either your call that method or you write duplicate code to reload that dataset. How is other code linking there?
ASKER
Ah ur right, its fine, thanks.
ASKER
Dim UpdateAD As New OMSystemDataSetTableAdapte
UpdateAD.Update(OMSDataSou
Thanks