Loading Datasets
-
I am trying to load up a dataset from an SQL table, after the first row the code is exited at the following line: dr = dt.NewRow(); There are 10,000 lines in the SQL table do you have any ideas on why this is happening. DataSet_I.BSDDataTable BSD = new DataSet_I.BSDDataTable(); if (strTableName == "xxxxx") { dt = BSD; if (Rowset != null && Rowset.IsOpen) { int nCol = 0; //int nCols = Rowset.Cols; Rowset.MoveFirst(); while (!Rowset.IsEOF) { dr = dt.NewRow(); **************EXITS CODE on 2nd PASS****************** foreach (DataColumn dc in dt.Columns) { nCol++; object dcValue = Rowset.GetData(nCol); if (dcValue != null) { if (dc.DataType == typeof(System.String)) dr[dc] = (string)Rowset.GetData(nCol); else if (dc.DataType == typeof(System.Int32)) dr[dc] = (int)Rowset.GetData(nCol); else if (dc.DataType == typeof(System.Single)) dr[dc] = (float)Rowset.GetData(nCol); else if (dc.DataType == typeof(System.DateTime)) dr[dc] = (DateTime)Rowset.GetData(nCol); } } dt.Rows.Add(dr); Rowset.MoveNext(); } } Also, can I assign a set number of rows to the DataTable before I start and just load without adding new rows. Any help would be greatly appreciated. Thanks in advance. Michael
-
I am trying to load up a dataset from an SQL table, after the first row the code is exited at the following line: dr = dt.NewRow(); There are 10,000 lines in the SQL table do you have any ideas on why this is happening. DataSet_I.BSDDataTable BSD = new DataSet_I.BSDDataTable(); if (strTableName == "xxxxx") { dt = BSD; if (Rowset != null && Rowset.IsOpen) { int nCol = 0; //int nCols = Rowset.Cols; Rowset.MoveFirst(); while (!Rowset.IsEOF) { dr = dt.NewRow(); **************EXITS CODE on 2nd PASS****************** foreach (DataColumn dc in dt.Columns) { nCol++; object dcValue = Rowset.GetData(nCol); if (dcValue != null) { if (dc.DataType == typeof(System.String)) dr[dc] = (string)Rowset.GetData(nCol); else if (dc.DataType == typeof(System.Int32)) dr[dc] = (int)Rowset.GetData(nCol); else if (dc.DataType == typeof(System.Single)) dr[dc] = (float)Rowset.GetData(nCol); else if (dc.DataType == typeof(System.DateTime)) dr[dc] = (DateTime)Rowset.GetData(nCol); } } dt.Rows.Add(dr); Rowset.MoveNext(); } } Also, can I assign a set number of rows to the DataTable before I start and just load without adding new rows. Any help would be greatly appreciated. Thanks in advance. Michael
Is there any exception? If yes then what is the exception message?
Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
-
Is there any exception? If yes then what is the exception message?
Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."