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

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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


    Helixpoint Guest

  2. Similar Questions and Discussions

    1. Fill a Dropdownlist in Datagrid template field based on the Row
      Basically I want to be able to do this: Have a Datagrid/DataList of Employees and the Dropdownlist will have their family member names that they...
    2. fill datagrid
      if i have two or more datagrids need to be filled , should i use two or more sqldataadapters, or only just use one sqldataadapter (by changing it's...
    3. editing text in swf using Sothink SWF Quicker
      Could someone enlighten me on how I can edit existing text in an existing SWF file using Sothink SWF Quicker? I am not a Flash developer, but I...
    4. Quicker Flash sites?
      Hi FYI - I just put up a brand new copy of Optimaze on http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=3616101286&ssPageName=ADME:B:LC:US:1 -...
    5. Fill datagrid without database
      Hello I need to fill in my datagrid from calcutalted date. how do I fill in my datagrid? yoramo
  3. #2

    Default Re: Looking for a quicker way to fill a datagrid???

    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" <dave@helixpoint.com> wrote in message
    news:eew7dGqVDHA.3332@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
    >
    >

    Alvin Bruney Guest

  4. #3

    Default Re: Looking for a quicker way to fill a datagrid???

    How much faster would a DataReader be? Doesn't Fill use a DataReader to fill
    the DataSet?
    --
    John Saunders
    Internet Engineer
    [email]john.saunders@surfcontrol.com[/email]

    "Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
    message news:%23NBbzL4VDHA.1180@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" <dave@helixpoint.com> wrote in message
    > news:eew7dGqVDHA.3332@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
    > >
    > >
    >
    >

    John Saunders Guest

  5. #4

    Default Re: Looking for a quicker way to fill a datagrid???

    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" <john.saunders@surfcontrol.com> wrote in message
    news:eHUbYl4VDHA.484@TK2MSFTNGP09.phx.gbl...
    > How much faster would a DataReader be? Doesn't Fill use a DataReader to
    fill
    > the DataSet?
    > --
    > John Saunders
    > Internet Engineer
    > [email]john.saunders@surfcontrol.com[/email]
    >
    > "Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
    > message news:%23NBbzL4VDHA.1180@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" <dave@helixpoint.com> wrote in message
    > > news:eew7dGqVDHA.3332@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
    > > >
    > > >
    > >
    > >
    >
    >

    Alvin Bruney Guest

  6. #5

    Default Re: Looking for a quicker way to fill a datagrid???

    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
    [email]john.saunders@surfcontrol.com[/email]

    "Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
    message news:ueZbU5%23VDHA.1180@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" <john.saunders@surfcontrol.com> wrote in message
    > news:eHUbYl4VDHA.484@TK2MSFTNGP09.phx.gbl...
    > > How much faster would a DataReader be? Doesn't Fill use a DataReader to
    > fill
    > > the DataSet?
    > > --
    > > John Saunders
    > > Internet Engineer
    > > [email]john.saunders@surfcontrol.com[/email]
    > >
    > > "Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote
    in
    > > message news:%23NBbzL4VDHA.1180@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" <dave@helixpoint.com> wrote in message
    > > > news:eew7dGqVDHA.3332@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
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    John Saunders Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139