Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 770
  • Last Modified:

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(LinesConnString)

         
LinesSelectSql = "Select * FROM WPFtblSmartQuoteLines where LinesAstuteRef = '" & FlxHeader(MyIndex, 8).Text.ToString & "'"
           

Try
'Open connect to OMSytem
    LinesConnConect.Open()
'Insert SQL Select COMMMAND above
    LinesConnAdapter.SelectCommand = New SqlCommand(LinesSelectSql, LinesConnConect)
'Run SQL Select Query
    LinesConnAdapter.SelectCommand.ExecuteNonQuery()

'Load Dataset with results..
    LinesConnAdapter.Fill(LinesSQDataset)

'Set Dateset to load into DbGrdGRNInfo
    FlxLine.ItemsSource = LinesSQDataset.Tables(0).DefaultView

'Clear SqlAdaptor
    LinesConnAdapter.Dispose()
    LinesSelectSql = Nothing
'Close Connection to OMSystem
    LinesConnConect.Close()


Catch ex As Exception
    MsgBox(ex.ToString)
End Try

End Sub
0
deanlee17
Asked:
deanlee17
  • 2
  • 2
1 Solution
 
CodeCruiserCommented:
Just execute the LoadLinesGrid sub again? You may have to put

LinesSQDataset.Tables.Clear()

before that.
0
 
deanlee17Author Commented:
Because of the way other code is linking in I cannot just re-run LoadLinesGrid. Can I force the dataset to refresh itself, found the code below but no idea how to change it to my needs....

        Dim UpdateAD As New OMSystemDataSetTableAdapters.tblGIQTableAdapter
        UpdateAD.Update(OMSDataSource.tblGIQ)


Thanks
0
 
CodeCruiserCommented:
Refreshing is reloading so either your call that method or you write duplicate code to reload that dataset. How is other code linking there?
0
 
deanlee17Author Commented:
Ah ur right, its fine, thanks.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now