Persist a dataset

  • Thread starter Thread starter Paul Ilacqua
  • Start date Start date
P

Paul Ilacqua

How do I persist a dataset to another procedure in a form IE
'Code

Public ds as Dataset
'Fill and use Dataset in LoadProjects but I want to use this dataset from
another sub in the same form class.


Private Sub LoadProjects()

Using objData As New OLEDBBase

ds = New DataSet

Try

With objData

..SQL = "Select PartNumber,Sum([OH INV]) From Inventory Group By PartNumber"

..InitializeCommand()

..OpenConnection()

'DS is Filled Here

..FillDataSet(ds, "Builds")

End With

Dim iCounter As Integer = 0

Dim row As DataRow

ListBox1.Items.Clear()

For Each row In ds.Tables(0).Rows

ListBox1.Items.Add(row(0))

Next row



objData.DataReader.Close()

ds.Clear()

Catch ExceptionErr As Exception

MessageBox.Show(ExceptionErr.Message, "Error")

End Try

End Using

End Sub
 
Hi Paul,

Don't call ds.Clear and pass ds to another method?
BTW, why do you need: objData.DataReader.Close()?
 
I was experimenting with a Datareader VS as dataset. I'm filling a Listbox
with part numbers with a data reader, then after clicking on a part number,
then I was getting an Inventory (single number) for that part number. Then I
thought I'll set up a dataset /datatable with the part number and the
inventory... fill the list box with the part number, then lookup the
inventory instead of continually hitting the db. I'm learning VB .NET & and
want to learn how to do things correctly.

How do I pass ds to another method?

Thank you for your help.

Miha Markic said:
Hi Paul,

Don't call ds.Clear and pass ds to another method?
BTW, why do you need: objData.DataReader.Close()?

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Paul Ilacqua said:
How do I persist a dataset to another procedure in a form IE
'Code

Public ds as Dataset
'Fill and use Dataset in LoadProjects but I want to use this dataset from
another sub in the same form class.


Private Sub LoadProjects()

Using objData As New OLEDBBase

ds = New DataSet

Try

With objData

.SQL = "Select PartNumber,Sum([OH INV]) From Inventory Group By
PartNumber"

.InitializeCommand()

.OpenConnection()

'DS is Filled Here

.FillDataSet(ds, "Builds")

End With

Dim iCounter As Integer = 0

Dim row As DataRow

ListBox1.Items.Clear()

For Each row In ds.Tables(0).Rows

ListBox1.Items.Add(row(0))

Next row



objData.DataReader.Close()

ds.Clear()

Catch ExceptionErr As Exception

MessageBox.Show(ExceptionErr.Message, "Error")

End Try

End Using

End Sub
 
As a parameter of type DataSet to the method

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Paul Ilacqua said:
I was experimenting with a Datareader VS as dataset. I'm filling a Listbox
with part numbers with a data reader, then after clicking on a part number,
then I was getting an Inventory (single number) for that part number. Then
I thought I'll set up a dataset /datatable with the part number and the
inventory... fill the list box with the part number, then lookup the
inventory instead of continually hitting the db. I'm learning VB .NET & and
want to learn how to do things correctly.

How do I pass ds to another method?

Thank you for your help.

Miha Markic said:
Hi Paul,

Don't call ds.Clear and pass ds to another method?
BTW, why do you need: objData.DataReader.Close()?

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Paul Ilacqua said:
How do I persist a dataset to another procedure in a form IE
'Code

Public ds as Dataset
'Fill and use Dataset in LoadProjects but I want to use this dataset
from another sub in the same form class.


Private Sub LoadProjects()

Using objData As New OLEDBBase

ds = New DataSet

Try

With objData

.SQL = "Select PartNumber,Sum([OH INV]) From Inventory Group By
PartNumber"

.InitializeCommand()

.OpenConnection()

'DS is Filled Here

.FillDataSet(ds, "Builds")

End With

Dim iCounter As Integer = 0

Dim row As DataRow

ListBox1.Items.Clear()

For Each row In ds.Tables(0).Rows

ListBox1.Items.Add(row(0))

Next row



objData.DataReader.Close()

ds.Clear()

Catch ExceptionErr As Exception

MessageBox.Show(ExceptionErr.Message, "Error")

End Try

End Using

End Sub
 
Back
Top