|
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. I asked this a few days ago and the code was asked for so here it is.
Please help,
Michael
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 "***".
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);
}
}
}
}
|
|
|
|
|
The array that you have declared in FillNameInfoArrayCS will be filled with data. If you declare another variable in another class, that variable will not automatically be filled with data also just because it happens to have the same name.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
The question is, if I fill the variable outside this class, how to insure the data is still available when calling from another class.
Michael
|
|
|
|
|
Wherever you keep the data, you need a reference to it in order to access it. Either a reference to the array or a reference to the object containing the array.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
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. I asked this a few days ago and the code was asked for so here it is.
Please help,
Michael
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 "***".
****** Note this is not all of the code the general idea ************
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();
}
}
}
}
|
|
|
|
|
Hey everyone,
I would like to use the opportunity to ask some questions that might have been asked before, if so please point me where because i haven't found it... if not please help me out because the due date to this project is coming closer...
I am having some, probably novice, problems when i am trying to connect to a database from Sql Server 2005.
This is the error i am getting:
" An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server )"
Honestly i don't know what to do. I have deattached the database to work directly and not luck. I also made sure that sql server is running. I see that the VS 2005 creates an app.config, how can i use it instead of coding the ConnectionString myself?
I would really appreciate any help because i am almost done with my final project and for the my server this is one of the features missing.
Now for the Microsoft finger print reader. I have been looking online for a SDK and most, if not all of them, always point to a free SDK at http://www.griaule.com but first i haven't been able to access the website or get the sdk from somewhere else. The latest i did was to try to go to DigitalPersona.com trying to get any sdk and prove it but no luck either.
I think my question would be: is there any way to handle the Finger print reader as an image scanner, if so how? Because all i want to do is to capture one image from one finger and save it to a database, to test the project but after that all i need is to compare the image from the fingerprint with an image from a database that will be given to me eventually. I think i know how to compare the images but without the image from the finger print i have nothing to work with !!!
Any help would be appreciated,
Thanks in advance...
Luis E Tineo S
|
|
|
|
|
how to write error in event using Event Log with date and time in c# windows application
lsa
|
|
|
|
|
|
hai all,
I am using one context menu in parent form, whereever i am clicking on the form ,the context menu is appearing, now, my problem is i am adding a child form in Mdi, child form contains one datagrid, if i am clicking on column header of datagrid ,a new context menu should display not the one in the parent form context menu. ya its coming,but again i am clicking whereever in the form(except coumn header) in child form, the parent form context menu is not appering, please help me how to do, i am new to programming field
thanks in advance..
faizal
ksf
|
|
|
|
|
faiznasi wrote: the parent form context menu is not appering, please help me how to do, i am new to programming field
I am not getting how you are expecting parent context menu to appear when clicking on child form ?
|
|
|
|
|
hai navaneeth,
I created one context menu and added into a parent from(parentMdi) properties, after that i am adding one child form to that parent mdi page. (the child is loaded into parent form) where ever i am clicking the parent form context menu is apperring, but i need to hide the context menu if i am clicking datagrid column header of child form(for that, in mouse down evnt of datagrid in child form, i wrote a code, if it is column header ,i am making a static variable to 1 and pass that variable to parent child and making as invissble, ya its working) one i hitted in datagrid column header, the parent contextmenu is disappearing, now my problem is if i am again clicking on the form(the parent form context menu should appear) its not appering, i think now u r understod my problem,, please suggest me how to do
thanks and regards
faizal
ksf
|
|
|
|
|
override the context menu to be display in the child form or set it to null if u don't want to display anything
|
|
|
|
|
How to write an error in event using Event Log with date and time in C# window applications
|
|
|
|
|
you can use Filestream class to write into a file and simply call that function in
try
{
//your code
}
catch {
//call logfunction here
}
so if any error occurs it will be logged into the file.
Regards.
Tasleem Arif
|
|
|
|
|
|
Why use a preprocessor variable instead of a normal one
Gaurav
|
|
|
|
|
G.K.M. wrote: Why use a preprocessor variable instead of a normal one
I guess it is executed in the compile time
|
|
|
|
|
A what? This is the C# forum.
|
|
|
|
|
How to Validate an XML Document by Using DTD, XDR in c# window applications
suman.c
|
|
|
|
|
|
I have a windows app connecting to a webservice. In some situation(s) (haven't narrowed it down enough), I get the following exception:
The underlying connection was closed: The connection was closed unexpectedly.
Please help.......
Regards
Pankaj Joshi
|
|
|
|
|
hi all
I have a .net web application. I need to copy a file present on the web server machine to a remote machine on the network. how is it possible? i tried using CopyTo(); methode. but not working. somebody told me that copy file is not possible in web application. but i think download file is possible only for website. then how is it done?
please help me.
|
|
|
|
|
P_Elza wrote: i think download file is possible only for website. then how is it done?
Use WebClient class and WebClient.DownLoadFile() method
|
|
|
|
|
The MSDN example at:
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_cscomp/html/ba881e38-2abf-4a5f-b9e6-28d26a5bd235.htm
Shows the following code and says it will throw an "Error Message: Use of possibly unassigned field 'field'; A field in a structure was used without first being initialized."
public struct error<br />
{<br />
public int i;<br />
}<br />
<br />
public class MyClass<br />
{<br />
public static void Main()<br />
{<br />
error e;<br />
System.Console.WriteLine( e.i );
}<br />
}
But it's my understanding that the compiler generated constructor for a struct automatically intializes the fields to zero, false, or null.
Since the struct in the example has no explicit constructor, why isn't i being initialized to zero?
|
|
|
|
|
Hi,
it is not related to your struct, the same is true for all value types, example:
public class MyClass {
public static void Main() {
int e;
System.Console.WriteLine( e );
}
}
i.e. local variables need explicit initialization.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|