Reading and writing DataSets
-
I loaded up a DataSet from an SQL table and was able to read it within the class in which I loaded the ds. However when I try to call the data from another class there is no data in the ds. Please help, Michael
-
Hi, Please Please Give Us Your Code So We Can Help Solve U'r Problems :confused:
Regards, Tomi
-
I have 2 pieces of code one for datasets and the other a class in which I have a similar problem, I did not include all of the code but the general idea is there. I will place the second in a different thread. Note that some of the syntax comes from a program called OleDBProNet for loading data from a database though this should not matter see where I can read data in "***". Class1 { DataSet_I dsI = new DataSet_I(); DataSet_I.BSecDataDataTable BSD = new DataSet_I.BSecDataDataTable(); public void buttonFillDataTables_Click(object sender, EventArgs e) { if (checkBoxOleDBProNet.Checked == true) { if (checkBoxFilldsIDataTables.Checked == true) FilldsI_DataTablesOleDBProNet(); string strGroup = BSD[200].strGroup; ******* Data does not show here line above***** } } } Class2 { DataSet_I dsI = new DataSet_I(); DataSet_I.BSecDataDataTable BSD = new DataSet_I.BSecDataDataTable(); FilldsI_DataTablesOleDBProNet(); { ShowRowset(); string strGroup = BSD[200].strGroup; ******* Data shows here ***** } public void ShowRowset() { Rowset.MoveFirst(); while (!Rowset.IsEOF) { BSD.NewBSecDataRow(); BSD.Rows.Add(nUseRecNumID); if (Rowset.GetData(1) != null) BSD[nUseRecNumID].nRecNumID = (Int32)Rowset.GetData(1); Rowset.MoveNext(); } } } }
-
public class NameInfoCS { public int historyHandle = -1; public int nRecNumID = 0; public string Name = ""; public int item = 0; } public class FillNamesInfoArrayCS { NameInfoCS[] NameInfoArray public void FillArray() { NameInfoArray = new NameInfoCS[Names.Length]; for (int idx = 0; idx < Names.Length; ++idx) { NameInfoArray[idx] = new NameInfoCS(); NameInfoArray[idx].Name = Names[idx]; NameInfoArray[idx].nRecNumID = idx + 1000; } } } private Class1 { private NameInfoCS[] NameInfoArray = new NameInfoCS[100]; ******* if I load data from FillNamesInfoArrayCS here there is no problem, but if I load FillNamesInfoArrayCS from outside of this class and then call this class the class has no data in it. “info.” Below shows as null, “NameInfoCS info in NameInfoArray” error message says I must use new **************** public void DATAMultipleHistory() { if (program.IsEntitled != 0) { program.ReleaseAllDATA(); foreach (NameInfoCS info in NameInfoArray) { info.historyHandle = program.get_RequestHistory(info.Name, info.strDATATP, IProgram.DATAType.btDATA, info.nNumberOfDATA); } } } }