|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DataTable performanceAt present we've got very few users and the web app flies along. All the data access is performed through a DAL and most of the data is return through DataTables. All code is in C# and all data access without exception is in the following style: <code> private DataTable myDataTable() { using (SqlConnection conn = new SqlConnection(mySQLConnection)) { DataTable dt = new DataTable(); SqlCommand cmd = new SqlCommand(mySp, conn); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; da.Fill(dt); return dt; } } </code> Is this preferable over using DataSets? Or would I be better off using DataReaders? A DataSet is just a collection of DataTables. So when you are using a
dataset, you are really using the tables in it. Having just a datatable is going to be less overhead then a dataset, since a dataset includes datatables. However, this overhead is minor, and should not be a factor. So, if you don't need the functionality of a dataset, then go ahead and use a datatable. Show quote "pinhead" <dlynes2***@gmail.com> wrote in message news:1144068761.073641.247810@u72g2000cwu.googlegroups.com... > Just a question on performance. I'm building an .Net2 web application. > At present we've got very few users and the web app flies along. All > the data access is performed through a DAL and most of the data is > return through DataTables. All code is in C# and all data access > without exception is in the following style: > > <code> > private DataTable myDataTable() > { > using (SqlConnection conn = new SqlConnection(mySQLConnection)) > { > DataTable dt = new DataTable(); > SqlCommand cmd = new SqlCommand(mySp, conn); > cmd.CommandType = CommandType.StoredProcedure; > SqlDataAdapter da = new SqlDataAdapter(); > da.SelectCommand = cmd; > da.Fill(dt); > return dt; > } > } > </code> > > Is this preferable over using DataSets? Or would I be better off using > DataReaders? > Marina,
Can you have a look in the newsgroup languages.VB there is a typical question for you. Foreign languages names Cor Show quote "Marina Levit [MVP]" <someone@nospam.com> schreef in bericht news:eE8yT6xVGHA.5468@TK2MSFTNGP14.phx.gbl... >A DataSet is just a collection of DataTables. So when you are using a >dataset, you are really using the tables in it. > > Having just a datatable is going to be less overhead then a dataset, since > a dataset includes datatables. However, this overhead is minor, and should > not be a factor. > > So, if you don't need the functionality of a dataset, then go ahead and > use a datatable. > > "pinhead" <dlynes2***@gmail.com> wrote in message > news:1144068761.073641.247810@u72g2000cwu.googlegroups.com... >> Just a question on performance. I'm building an .Net2 web application. >> At present we've got very few users and the web app flies along. All >> the data access is performed through a DAL and most of the data is >> return through DataTables. All code is in C# and all data access >> without exception is in the following style: >> >> <code> >> private DataTable myDataTable() >> { >> using (SqlConnection conn = new SqlConnection(mySQLConnection)) >> { >> DataTable dt = new DataTable(); >> SqlCommand cmd = new SqlCommand(mySp, conn); >> cmd.CommandType = CommandType.StoredProcedure; >> SqlDataAdapter da = new SqlDataAdapter(); >> da.SelectCommand = cmd; >> da.Fill(dt); >> return dt; >> } >> } >> </code> >> >> Is this preferable over using DataSets? Or would I be better off using >> DataReaders? >> > > I did answer him the best I could, though I'm not sure I was much help. I'm
Russian, but been in the US since childhood... Thanks for thinking of me :) Show quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:ewo6iHyVGHA.1868@TK2MSFTNGP09.phx.gbl... > Marina, > > Can you have a look in the newsgroup languages.VB there is a typical > question for you. > > Foreign languages names > > Cor > > "Marina Levit [MVP]" <someone@nospam.com> schreef in bericht > news:eE8yT6xVGHA.5468@TK2MSFTNGP14.phx.gbl... >>A DataSet is just a collection of DataTables. So when you are using a >>dataset, you are really using the tables in it. >> >> Having just a datatable is going to be less overhead then a dataset, >> since a dataset includes datatables. However, this overhead is minor, and >> should not be a factor. >> >> So, if you don't need the functionality of a dataset, then go ahead and >> use a datatable. >> >> "pinhead" <dlynes2***@gmail.com> wrote in message >> news:1144068761.073641.247810@u72g2000cwu.googlegroups.com... >>> Just a question on performance. I'm building an .Net2 web application. >>> At present we've got very few users and the web app flies along. All >>> the data access is performed through a DAL and most of the data is >>> return through DataTables. All code is in C# and all data access >>> without exception is in the following style: >>> >>> <code> >>> private DataTable myDataTable() >>> { >>> using (SqlConnection conn = new SqlConnection(mySQLConnection)) >>> { >>> DataTable dt = new DataTable(); >>> SqlCommand cmd = new SqlCommand(mySp, conn); >>> cmd.CommandType = CommandType.StoredProcedure; >>> SqlDataAdapter da = new SqlDataAdapter(); >>> da.SelectCommand = cmd; >>> da.Fill(dt); >>> return dt; >>> } >>> } >>> </code> >>> >>> Is this preferable over using DataSets? Or would I be better off using >>> DataReaders? >>> >> >> > > Pinhead,
In addition for the rest on the answer from Marina. > Is this preferable over using DataSets? Or would I be better off using The dataset/datatable use the datareader as what Marina wrote for DataTable > DataReaders? > instead of DataSet is as well for this However, have a look to this. There is more written about yor question on MSDN http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadonet/html/datasetenhance.aspI hope this helps,Cor |
|||||||||||||||||||||||