|
Because you have a list of base objects, the derived properties will not be there. Your best bet is to create an enum of class types, and make each class type tell you what it is via the enum. Or, find a way to offer a common, base interface that can do the different things you want via polymorphism ( so, timeStemp is defined in the base class, and holds a value that's valid relative to the type of object you have ). Only things derived in the base will be visible, your only other route is to use is or as.
As in
MessageB mesB = myMessageA as MessageB;
if (mesB != null)
{
// It was of MessageB type.
// mesB now has the full MessageB interface.
}
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks for your suggestions,
If I write it that way, is it to costy???????????
PointPairList angleTimeArr = new PointPairList();
for (int i = 0; i < fileMessages.Count; i++)
{
angleTimeArr.Add((fileMessages[i] as Clusters.CSensorStatus).valveAngDeg , )
}
should I instead do as you said and implement a base interface or enum, will it improve
performance in a significant way???
|
|
|
|
|
If you know for sure that they are all of this type, then just make your list of this type. Any that are not, will come back null and throw an exception.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi ,
Am getting this error, how can I rectify this?
Data is Null. This method or property cannot be called on Null values.
Can anyone help me out in solving this issue?
Thanks,
Mirunab
|
|
|
|
|
By making sure that the method or property you have is not null? You can try giving it a default value at instantiation.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
"There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib
|
|
|
|
|
Hi,
I am REALLY new to C#, can someone please help...
How do I Insert the values of 2 textboxes directly into a database?
Example:
textbox1 = name
textbox2 = surname
Database has a table caled "test_tbl" with 2 columns. One called "name" the other "surname"
Kind Regards
|
|
|
|
|
|
I found a number of articles regarding inserting into Databases but most of them I did not understand. I appologize if my question is too simple for you. No need to get nasty about it. Everybody needs to learn sometime...
But thank you for your inputs, I did manage to find the following though and got it to work:
SqlConnection conn = new SqlConnection(_connection);
SqlCommand cmd = new SqlCommand(_query, conn);
conn.Open();
object returnVal = cmd.ExecuteScalar();
conn.Close();
Regards
|
|
|
|
|
He didn't get nasty with you. He pointed out a basic fact that there are other things to learn about before you start with database issues. Believe me, you'd know if he'd got nasty.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
My apologies then for misunderstanding him.
Unfortunately I have to do the Database thing now, I have something that needs to be done in 2 weeks and is mostly db work and I have to learn it all in 2 weeks.
Thanks anyways
|
|
|
|
|
Is this a class, or paid work ?
Either way, you need to buy a book and get stuck into it. We can't really offer consistent help at the level that you're asking for it, it's just not possible.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
you have two text boxes
int x=int.parse(textbox1.text)
int y=int.parse(textbox2.text)
SqlConnection cn = new SqlConnection(//but here your connection string);
cn.Open();
cm = new SqlCommand("INSERT INTO teble_name VALUES(" + x + "," + y + " ) ", cn);
cm.ExecuteNonQuery();
and here you insert the record you want
If I HaD OnE sInglE wIsh IwIll gO back for thE fIrst tIme i sEE yOu
|
|
|
|
|
Islam9 wrote: int x=int.parse(textbox1.text)
int y=int.parse(textbox2.text)
SqlConnection cn = new SqlConnection(//but here your connection string);
cn.Open();
cm = new SqlCommand("INSERT INTO teble_name VALUES(" + x + "," + y + " ) ", cn);
cm.ExecuteNonQuery();
This has errors:
Parse has a capital P
Text has a capital T
Your insert statement is attempting to concatenate integers into a string.
Your insert statement is susceptable to a SQL Injection Attack. Please learn how to prevent them[^]
|
|
|
|
|
instead of telling me my errors
ihope ou tell us the right way to do the requier
thank you
If I HaD OnE sInglE wIsh IwIll gO back for thE fIrst tIme i sEE yOu
|
|
|
|
|
Islam9 wrote: instead of telling me my errors
ihope ou tell us the right way to do the requier
I did! I gave you a link to an article that tells you what you should be doing.
The other errors highlighted are sufficiently easy to correct I didn't think an explanation was necessary.
int x=int.parse(textbox1.text);
parse should be Parse
text should be Text
The other two errors can be corrected by reading, understanding and implementing the recommendations in the article that was linked: http://www.codeproject.com/cs/database/SqlInjectionAttacks.asp[^]
|
|
|
|
|
Hi
We are using Visual Studio 2005, C# and SQL Server 2005. We are developing a system that is a combination of some Windows Application modules and a Web application (intranet). We have a number of maintenance processes that we would like to schedule to run automatically a few times a day. What is good way of handling scheduling in this type of scenario?
Second questions is whether we could create Web Services to handle these maintenance processes and schedule the system to consume the web services at regular intervals.
Any advice will be appreciated.
Thanks
Kobus
|
|
|
|
|
Your second question answers for the first. That is a good method of creating webservice to handle schedule process. You need to create a windows application too, which request to the webservice frequently.
|
|
|
|
|
For First Question:
Yes we can execute maintenance processes that we would like to schedule to run automatically a few times a day. in sql server by providing a mechanism
SQL SERVER INTEGRATED SERVICE(DTS).
On which you do every code script on the FLY.
Thanks & Regards
Tarini Singh
Sr. Software Engineer. (IT)
tksingh@zentagroup.com
|
|
|
|
|
For First Question:
Yes we can execute maintenance processes that we would like to schedule to run automatically a few times a day. in sql server by providing a mechanism
SQL SERVER INTEGRATED SERVICE(DTS).
On which you do every code script on the FLY.
Thanks & Regards
Tarini Singh
Sr. Software Engineer. (IT)
tksingh@zentagroup.com
|
|
|
|
|
Start|Programs|Accessories|System Tools|Scheduled Tasks
|
|
|
|
|
Hello there,
I have a bunch of tables that must be created in oracle while installing my c# application, any idea how to make that happen?? currently I'm saving my tables ddl statements in a .sql file.
Many thanks
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Can you execute a query against an Oracle database from C# code? I guess you must be doing it in you app. Can't you execute the CREATE TABLE statements the same way?
|
|
|
|
|
Thank you chopeen
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
1. I had to put my DDL statements in a text document.
2. Make sure your statements are followed by /
3. Save it to YourScriptFile.sql
4. Create a batch file in which you are calling sqlplus YourScriptFile.sql
5. In your windows form, call that batch file using a process.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi
I need to create a temporary unique id on a offline computer.
The item will get a unique id (in our server, not worldwide!) when it connects to the server. But how do i ensure that a temporary id is unique until i get access to the server?
The only decent solution i have come up with is to use DateTime.Now.Ticks. But that could go fubar if the clock is changed.
Is that another better way to do it?
The id doesn't have to be globaly unique, just unique for the active computer.
"Life would be alot easier if i only had the sourcecode!"
|
|
|
|