[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Re-fill dataset with different select statement

Posted on 2009-05-13
2
Medium Priority
?
407 Views
Last Modified: 2012-05-06
I have a procedure that fills an FPSpread/Grid.
In this procedure I need to check and see if there are any records in the first dataset and if not I need to refill the dataset with a different select string.
What would be the best way to do this?
Thanks
Function FillSpread() As DataTable
        Dim ds As New DataSet
 
        If DatabaseToUse() = BizObjs.DBType.Access Then
 
            Dim str As String = String.Empty
 
            If mbTaskCars Then
                str = SelectTaskCars()
            ElseIf mbTaskDetailsLU Then
                str = SelectTaskDetailsLU()
 
            End If
 
            Dim dc As New OleDb.OleDbConnection(ConnectionString)
            Dim da As New OleDb.OleDbDataAdapter(str, dc)
 
            Try
 
                da.Fill(ds)
                If ds.Tables(0).Rows.Count = 0 Then
 
                    ds.Clear()
                    
 
                End If
                dc.Close()
 
 
            Catch ex As Exception
                MessageBox.Show(ex.Message)
                dc.Close()
 
            End Try
        End If
 
        Return GenerateDataTable(ds)
 
    End Function

Open in new window

0
Comment
Question by:Sheritlw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 2000 total points
ID: 24381849
try something like this
 Function FillSpread() As DataTable
        Dim ds As New DataSet
 
        If DatabaseToUse() = BizObjs.DBType.Access Then
 
            Dim str As String = String.Empty
 
            If mbTaskCars Then
                str = SelectTaskCars()
            ElseIf mbTaskDetailsLU Then
                str = SelectTaskDetailsLU()
 
            End If
 
            Dim dc As New OleDb.OleDbConnection(ConnectionString)
            Dim da As New OleDb.OleDbDataAdapter(str, dc)
 
            Try
 
                da.Fill(ds)
                If ds.Tables(0).Rows.Count = 0 Then
 
                    ds.Clear()
                    str = " New Select stattemet"
                    Dim daNew As New OleDb.OleDbDataAdapter(str, dc)
                    daNew.Fill(ds)
                End If
                dc.Close()
 
 
            Catch ex As Exception
                MessageBox.Show(ex.Message)
                dc.Close()
 
            End Try
        End If
 
        Return GenerateDataTable(ds)
 
    End Function

Open in new window

0
 

Author Comment

by:Sheritlw
ID: 24382228
Thank you. That is what I finally figured out.  
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question