473,385 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Looking for a quicker way to fill a datagrid???

Here is my code:

Dim availMach As New ASPNETProduct.machinedb()

Dim dstMachList As DataSet

dstMachList = availMach.GetAvailMach(theSearchVal, theSearchBy,
theMachCode1, theSearchView, SelSort, SelSortDir)

availMachList.DataSource = dstMachList

Public Function GetAvailMach(ByVal theSearchVal As String, ByVal theSearchBy
As String, ByVal MACH_CODE1 As String, ByVal theSearchView As String, ByVal
SelSort As String, ByVal SelSortDir As String) As DataSet

' Create Instance of Connection and Command Object

Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("c onnectionString"))

Dim myCommand As New SqlDataAdapter("SelectOpenInventory", myConnection)

' Mark the Command as a SPROC

myCommand.SelectCommand.CommandType = CommandType.StoredProcedure

' Add Parameters to SPROC

Dim parametertheSearchVal As New SqlParameter("@theSearchVal",
SqlDbType.NVarChar, 100)

parametertheSearchVal.Value = theSearchVal

myCommand.SelectCommand.Parameters.Add(parameterth eSearchVal)

Dim parametertheSearchBy As New SqlParameter("@theSearchBy",
SqlDbType.NVarChar, 100)

parametertheSearchBy.Value = theSearchBy

myCommand.SelectCommand.Parameters.Add(parameterth eSearchBy)

Dim parameterMACH_CODE1 As New SqlParameter("@MACH_CODE",
SqlDbType.NVarChar, 50)

parameterMACH_CODE1.Value = MACH_CODE1

myCommand.SelectCommand.Parameters.Add(parameterMA CH_CODE1)

Dim parametertheSearchView As New SqlParameter("@theSearchView",
SqlDbType.NVarChar, 50)

parametertheSearchView.Value = theSearchView

myCommand.SelectCommand.Parameters.Add(parameterth eSearchView)

Dim parameterSelSort As New SqlParameter("@SelSort", SqlDbType.NVarChar, 50)

parameterSelSort.Value = SelSort

myCommand.SelectCommand.Parameters.Add(parameterSe lSort)

Dim parameterSelSortDir As New SqlParameter("@SelSortDir",
SqlDbType.NVarChar, 10)

parameterSelSortDir.Value = SelSortDir

myCommand.SelectCommand.Parameters.Add(parameterSe lSortDir)

' Create and Fill the DataSet

Dim myDataSet As New DataSet

myCommand.Fill(myDataSet)

' Return the datareader

Return myDataSet

End Function
--

dave
Nov 17 '05 #1
5 1920
if fill is not fast enough for you, use a datareader to loop thru. remember
the reader is a fire hose cursor and you have to explicitly close it when
done or else it is considered blocked.

"Helixpoint" <da**@helixpoint.com> wrote in message
news:ee**************@tk2msftngp13.phx.gbl...
Here is my code:

Dim availMach As New ASPNETProduct.machinedb()

Dim dstMachList As DataSet

dstMachList = availMach.GetAvailMach(theSearchVal, theSearchBy,
theMachCode1, theSearchView, SelSort, SelSortDir)

availMachList.DataSource = dstMachList

Public Function GetAvailMach(ByVal theSearchVal As String, ByVal theSearchBy As String, ByVal MACH_CODE1 As String, ByVal theSearchView As String, ByVal SelSort As String, ByVal SelSortDir As String) As DataSet

' Create Instance of Connection and Command Object

Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("c onnectionString"))

Dim myCommand As New SqlDataAdapter("SelectOpenInventory", myConnection)

' Mark the Command as a SPROC

myCommand.SelectCommand.CommandType = CommandType.StoredProcedure

' Add Parameters to SPROC

Dim parametertheSearchVal As New SqlParameter("@theSearchVal",
SqlDbType.NVarChar, 100)

parametertheSearchVal.Value = theSearchVal

myCommand.SelectCommand.Parameters.Add(parameterth eSearchVal)

Dim parametertheSearchBy As New SqlParameter("@theSearchBy",
SqlDbType.NVarChar, 100)

parametertheSearchBy.Value = theSearchBy

myCommand.SelectCommand.Parameters.Add(parameterth eSearchBy)

Dim parameterMACH_CODE1 As New SqlParameter("@MACH_CODE",
SqlDbType.NVarChar, 50)

parameterMACH_CODE1.Value = MACH_CODE1

myCommand.SelectCommand.Parameters.Add(parameterMA CH_CODE1)

Dim parametertheSearchView As New SqlParameter("@theSearchView",
SqlDbType.NVarChar, 50)

parametertheSearchView.Value = theSearchView

myCommand.SelectCommand.Parameters.Add(parameterth eSearchView)

Dim parameterSelSort As New SqlParameter("@SelSort", SqlDbType.NVarChar, 50)
parameterSelSort.Value = SelSort

myCommand.SelectCommand.Parameters.Add(parameterSe lSort)

Dim parameterSelSortDir As New SqlParameter("@SelSortDir",
SqlDbType.NVarChar, 10)

parameterSelSortDir.Value = SelSortDir

myCommand.SelectCommand.Parameters.Add(parameterSe lSortDir)

' Create and Fill the DataSet

Dim myDataSet As New DataSet

myCommand.Fill(myDataSet)

' Return the datareader

Return myDataSet

End Function
--

dave

Nov 17 '05 #2
How much faster would a DataReader be? Doesn't Fill use a DataReader to fill
the DataSet?
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
if fill is not fast enough for you, use a datareader to loop thru. remember the reader is a fire hose cursor and you have to explicitly close it when
done or else it is considered blocked.

"Helixpoint" <da**@helixpoint.com> wrote in message
news:ee**************@tk2msftngp13.phx.gbl...
Here is my code:

Dim availMach As New ASPNETProduct.machinedb()

Dim dstMachList As DataSet

dstMachList = availMach.GetAvailMach(theSearchVal, theSearchBy,
theMachCode1, theSearchView, SelSort, SelSortDir)

availMachList.DataSource = dstMachList

Public Function GetAvailMach(ByVal theSearchVal As String, ByVal

theSearchBy
As String, ByVal MACH_CODE1 As String, ByVal theSearchView As String,

ByVal
SelSort As String, ByVal SelSortDir As String) As DataSet

' Create Instance of Connection and Command Object

Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("c onnectionString"))

Dim myCommand As New SqlDataAdapter("SelectOpenInventory", myConnection)

' Mark the Command as a SPROC

myCommand.SelectCommand.CommandType = CommandType.StoredProcedure

' Add Parameters to SPROC

Dim parametertheSearchVal As New SqlParameter("@theSearchVal",
SqlDbType.NVarChar, 100)

parametertheSearchVal.Value = theSearchVal

myCommand.SelectCommand.Parameters.Add(parameterth eSearchVal)

Dim parametertheSearchBy As New SqlParameter("@theSearchBy",
SqlDbType.NVarChar, 100)

parametertheSearchBy.Value = theSearchBy

myCommand.SelectCommand.Parameters.Add(parameterth eSearchBy)

Dim parameterMACH_CODE1 As New SqlParameter("@MACH_CODE",
SqlDbType.NVarChar, 50)

parameterMACH_CODE1.Value = MACH_CODE1

myCommand.SelectCommand.Parameters.Add(parameterMA CH_CODE1)

Dim parametertheSearchView As New SqlParameter("@theSearchView",
SqlDbType.NVarChar, 50)

parametertheSearchView.Value = theSearchView

myCommand.SelectCommand.Parameters.Add(parameterth eSearchView)

Dim parameterSelSort As New SqlParameter("@SelSort", SqlDbType.NVarChar,

50)

parameterSelSort.Value = SelSort

myCommand.SelectCommand.Parameters.Add(parameterSe lSort)

Dim parameterSelSortDir As New SqlParameter("@SelSortDir",
SqlDbType.NVarChar, 10)

parameterSelSortDir.Value = SelSortDir

myCommand.SelectCommand.Parameters.Add(parameterSe lSortDir)

' Create and Fill the DataSet

Dim myDataSet As New DataSet

myCommand.Fill(myDataSet)

' Return the datareader

Return myDataSet

End Function
--

dave


Nov 17 '05 #3
underneath it does but there is a lot of extra overhead because the results
have to be packaged and stuffed into a dataset. the performance difference
is night and day.

"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:eH*************@TK2MSFTNGP09.phx.gbl...
How much faster would a DataReader be? Doesn't Fill use a DataReader to fill the DataSet?
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
if fill is not fast enough for you, use a datareader to loop thru.

remember
the reader is a fire hose cursor and you have to explicitly close it when done or else it is considered blocked.

"Helixpoint" <da**@helixpoint.com> wrote in message
news:ee**************@tk2msftngp13.phx.gbl...
Here is my code:

Dim availMach As New ASPNETProduct.machinedb()

Dim dstMachList As DataSet

dstMachList = availMach.GetAvailMach(theSearchVal, theSearchBy,
theMachCode1, theSearchView, SelSort, SelSortDir)

availMachList.DataSource = dstMachList

Public Function GetAvailMach(ByVal theSearchVal As String, ByVal

theSearchBy
As String, ByVal MACH_CODE1 As String, ByVal theSearchView As String,

ByVal
SelSort As String, ByVal SelSortDir As String) As DataSet

' Create Instance of Connection and Command Object

Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("c onnectionString"))

Dim myCommand As New SqlDataAdapter("SelectOpenInventory", myConnection)
' Mark the Command as a SPROC

myCommand.SelectCommand.CommandType = CommandType.StoredProcedure

' Add Parameters to SPROC

Dim parametertheSearchVal As New SqlParameter("@theSearchVal",
SqlDbType.NVarChar, 100)

parametertheSearchVal.Value = theSearchVal

myCommand.SelectCommand.Parameters.Add(parameterth eSearchVal)

Dim parametertheSearchBy As New SqlParameter("@theSearchBy",
SqlDbType.NVarChar, 100)

parametertheSearchBy.Value = theSearchBy

myCommand.SelectCommand.Parameters.Add(parameterth eSearchBy)

Dim parameterMACH_CODE1 As New SqlParameter("@MACH_CODE",
SqlDbType.NVarChar, 50)

parameterMACH_CODE1.Value = MACH_CODE1

myCommand.SelectCommand.Parameters.Add(parameterMA CH_CODE1)

Dim parametertheSearchView As New SqlParameter("@theSearchView",
SqlDbType.NVarChar, 50)

parametertheSearchView.Value = theSearchView

myCommand.SelectCommand.Parameters.Add(parameterth eSearchView)

Dim parameterSelSort As New SqlParameter("@SelSort",
SqlDbType.NVarChar, 50)

parameterSelSort.Value = SelSort

myCommand.SelectCommand.Parameters.Add(parameterSe lSort)

Dim parameterSelSortDir As New SqlParameter("@SelSortDir",
SqlDbType.NVarChar, 10)

parameterSelSortDir.Value = SelSortDir

myCommand.SelectCommand.Parameters.Add(parameterSe lSortDir)

' Create and Fill the DataSet

Dim myDataSet As New DataSet

myCommand.Fill(myDataSet)

' Return the datareader

Return myDataSet

End Function
--

dave



Nov 17 '05 #4
Interesting. I'll have to do some performance tests on that some day. I had
thought that, absent DataRelations, they'd just loop through the DataReader,
calling:

DataSet ds = something();
DataTable dt = ds.Tables[0];
DataReader reader = somethingElse();

while (reader.Read())
{
DataRow dr = dt.NewRow();
dr.ItemArray = reader.GetValues();
dt.Rows.Add(dr);
}

Oh, well, one more mystery...
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
message news:ue****************@TK2MSFTNGP11.phx.gbl...
underneath it does but there is a lot of extra overhead because the results have to be packaged and stuffed into a dataset. the performance difference
is night and day.

"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:eH*************@TK2MSFTNGP09.phx.gbl...
How much faster would a DataReader be? Doesn't Fill use a DataReader to

fill
the DataSet?
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
if fill is not fast enough for you, use a datareader to loop thru.

remember
the reader is a fire hose cursor and you have to explicitly close it

when done or else it is considered blocked.

"Helixpoint" <da**@helixpoint.com> wrote in message
news:ee**************@tk2msftngp13.phx.gbl...
> Here is my code:
>
> Dim availMach As New ASPNETProduct.machinedb()
>
> Dim dstMachList As DataSet
>
> dstMachList = availMach.GetAvailMach(theSearchVal, theSearchBy,
> theMachCode1, theSearchView, SelSort, SelSortDir)
>
> availMachList.DataSource = dstMachList
>
>
>
>
>
> Public Function GetAvailMach(ByVal theSearchVal As String, ByVal
theSearchBy
> As String, ByVal MACH_CODE1 As String, ByVal theSearchView As String, ByVal
> SelSort As String, ByVal SelSortDir As String) As DataSet
>
> ' Create Instance of Connection and Command Object
>
> Dim myConnection As New
> SqlConnection(ConfigurationSettings.AppSettings("c onnectionString"))
>
> Dim myCommand As New SqlDataAdapter("SelectOpenInventory", myConnection) >
> ' Mark the Command as a SPROC
>
> myCommand.SelectCommand.CommandType = CommandType.StoredProcedure
>
> ' Add Parameters to SPROC
>
> Dim parametertheSearchVal As New SqlParameter("@theSearchVal",
> SqlDbType.NVarChar, 100)
>
> parametertheSearchVal.Value = theSearchVal
>
> myCommand.SelectCommand.Parameters.Add(parameterth eSearchVal)
>
> Dim parametertheSearchBy As New SqlParameter("@theSearchBy",
> SqlDbType.NVarChar, 100)
>
> parametertheSearchBy.Value = theSearchBy
>
> myCommand.SelectCommand.Parameters.Add(parameterth eSearchBy)
>
>
>
> Dim parameterMACH_CODE1 As New SqlParameter("@MACH_CODE",
> SqlDbType.NVarChar, 50)
>
> parameterMACH_CODE1.Value = MACH_CODE1
>
> myCommand.SelectCommand.Parameters.Add(parameterMA CH_CODE1)
>
>
>
> Dim parametertheSearchView As New SqlParameter("@theSearchView",
> SqlDbType.NVarChar, 50)
>
> parametertheSearchView.Value = theSearchView
>
> myCommand.SelectCommand.Parameters.Add(parameterth eSearchView)
>
> Dim parameterSelSort As New SqlParameter("@SelSort", SqlDbType.NVarChar, 50)
>
> parameterSelSort.Value = SelSort
>
> myCommand.SelectCommand.Parameters.Add(parameterSe lSort)
>
> Dim parameterSelSortDir As New SqlParameter("@SelSortDir",
> SqlDbType.NVarChar, 10)
>
> parameterSelSortDir.Value = SelSortDir
>
> myCommand.SelectCommand.Parameters.Add(parameterSe lSortDir)
>
>
>
>
>
> ' Create and Fill the DataSet
>
> Dim myDataSet As New DataSet
>
> myCommand.Fill(myDataSet)
>
> ' Return the datareader
>
> Return myDataSet
>
> End Function
>
>
> --
>
> dave
>
>



Nov 17 '05 #5
Interesting. I'll have to do some performance tests on that some day. I had
thought that, absent DataRelations, they'd just loop through the DataReader,
calling:

DataSet ds = something();
DataTable dt = ds.Tables[0];
DataReader reader = somethingElse();

while (reader.Read())
{
DataRow dr = dt.NewRow();
dr.ItemArray = reader.GetValues();
dt.Rows.Add(dr);
}

Oh, well, one more mystery...
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
message news:ue****************@TK2MSFTNGP11.phx.gbl...
underneath it does but there is a lot of extra overhead because the results have to be packaged and stuffed into a dataset. the performance difference
is night and day.

"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:eH*************@TK2MSFTNGP09.phx.gbl...
How much faster would a DataReader be? Doesn't Fill use a DataReader to

fill
the DataSet?
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
if fill is not fast enough for you, use a datareader to loop thru.

remember
the reader is a fire hose cursor and you have to explicitly close it

when done or else it is considered blocked.

"Helixpoint" <da**@helixpoint.com> wrote in message
news:ee**************@tk2msftngp13.phx.gbl...
> Here is my code:
>
> Dim availMach As New ASPNETProduct.machinedb()
>
> Dim dstMachList As DataSet
>
> dstMachList = availMach.GetAvailMach(theSearchVal, theSearchBy,
> theMachCode1, theSearchView, SelSort, SelSortDir)
>
> availMachList.DataSource = dstMachList
>
>
>
>
>
> Public Function GetAvailMach(ByVal theSearchVal As String, ByVal
theSearchBy
> As String, ByVal MACH_CODE1 As String, ByVal theSearchView As String, ByVal
> SelSort As String, ByVal SelSortDir As String) As DataSet
>
> ' Create Instance of Connection and Command Object
>
> Dim myConnection As New
> SqlConnection(ConfigurationSettings.AppSettings("c onnectionString"))
>
> Dim myCommand As New SqlDataAdapter("SelectOpenInventory", myConnection) >
> ' Mark the Command as a SPROC
>
> myCommand.SelectCommand.CommandType = CommandType.StoredProcedure
>
> ' Add Parameters to SPROC
>
> Dim parametertheSearchVal As New SqlParameter("@theSearchVal",
> SqlDbType.NVarChar, 100)
>
> parametertheSearchVal.Value = theSearchVal
>
> myCommand.SelectCommand.Parameters.Add(parameterth eSearchVal)
>
> Dim parametertheSearchBy As New SqlParameter("@theSearchBy",
> SqlDbType.NVarChar, 100)
>
> parametertheSearchBy.Value = theSearchBy
>
> myCommand.SelectCommand.Parameters.Add(parameterth eSearchBy)
>
>
>
> Dim parameterMACH_CODE1 As New SqlParameter("@MACH_CODE",
> SqlDbType.NVarChar, 50)
>
> parameterMACH_CODE1.Value = MACH_CODE1
>
> myCommand.SelectCommand.Parameters.Add(parameterMA CH_CODE1)
>
>
>
> Dim parametertheSearchView As New SqlParameter("@theSearchView",
> SqlDbType.NVarChar, 50)
>
> parametertheSearchView.Value = theSearchView
>
> myCommand.SelectCommand.Parameters.Add(parameterth eSearchView)
>
> Dim parameterSelSort As New SqlParameter("@SelSort", SqlDbType.NVarChar, 50)
>
> parameterSelSort.Value = SelSort
>
> myCommand.SelectCommand.Parameters.Add(parameterSe lSort)
>
> Dim parameterSelSortDir As New SqlParameter("@SelSortDir",
> SqlDbType.NVarChar, 10)
>
> parameterSelSortDir.Value = SelSortDir
>
> myCommand.SelectCommand.Parameters.Add(parameterSe lSortDir)
>
>
>
>
>
> ' Create and Fill the DataSet
>
> Dim myDataSet As New DataSet
>
> myCommand.Fill(myDataSet)
>
> ' Return the datareader
>
> Return myDataSet
>
> End Function
>
>
> --
>
> dave
>
>



Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: M. Craig | last post by:
I'm trying to display multiple resultsets, returned in a SQLDataReader, in a single table. The number of resultsets returned is variable, usually 3 or 4. Basically, each resultset has 1 row and I'd...
6
by: JeffB | last post by:
I have tried several different methods of getting a datagrid to fill with information. Below is the code I'm now using. When viewed in the browser and the text box filled with a parameter value...
4
by: Dave Edwards | last post by:
I understand that I can fill a datagrid with multiple queries, but I cannot figure out how to fill a dataset with the same query but run against multiple SQL servers, the query , table structure...
4
by: jaYPee | last post by:
I have 1 dataset called "dataset1" that contains 2 tables called "course" and "courseload". in my form i have a datagrid. the datasource of this datagrid is "dataset1" and the datamember is...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.