|
Yes, Nick makes a good point there with events and delegates. I guess the rest is up to you
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
How do I execute a stored procedure in the Page_Load function of C#?
Thanks!
Illegal Operation
WannaBe and GonnaBe Systems Developer
|
|
|
|
|
|
thanks for the help.
Just one more question?
Where does the "myReader" fit into the picture? I have inserted the line:
myReader = MyProc.executeReader();
Thanks!
Illegal Operation
WannaBe and GonnaBe Systems Developer
|
|
|
|
|
|
I have an item that is a tag value to a list view, and the list view item is also contained in the object. The relationship is two way.
My question is, if i remove these objects, will it persist in memory due to the fact that they refference each other?
From what i've read of the Garbage collector, it will perform a graph search for all objects reachable from root objects. So even if my two objects DO refference each other, they will be removed if they are unreachable from the root objects.
Is this right?
Cheers
Cata
|
|
|
|
|
That's right. It will remove them.
WM.
What about weapons of mass-construction?
|
|
|
|
|
Hi, is it possible to include the myApp.exe.manifest file in the exe file so that I don't have to have two separate files, one exe and one manifest? If so, how should I do this? (Visual Studio .NET 2003, C#)
|
|
|
|
|
|
hi,
i have made a service wich loads a another program ,my codes are correct but when i use these codes in my service,they dont work.
here is my codes:
<br />
System.IO.Directory.SetCurrentDirectory(myappPath);<br />
Process.Start("MyApplication" );<br />
i want to know why it happens?
|
|
|
|
|
What does not work?
Does the application not start? Have you checked with the TaskManager if it really does not start or is it started and you can't just see it?
Normally, a service application cannot interact with the desktop. Because of that, if you start an application from a service, the application will not be visible to the user.
To allow a service to interact with the desktop open the Service Control Manager. Select your service and open the properties.
- Select the "Log On" tab
- Select "Log on as: Local System account" and enter a valid account and password
- Check "Allow service to interact with desktop.
hth
Claudio
Claudio's Website
Hommingberger Gepardenforelle
|
|
|
|
|
Hi folks,
I need to write a piece of code that will list all the files in a folder in another machine.
Could you guys give me a hint?
Thanks.
|
|
|
|
|
you can set up the sharing on the another computer and access the directory directly using System.IO.Directory or make some sort of simple service which will send the data on request via tcp/ip protocol.
|
|
|
|
|
1.Value types are allocated on stack and Reference types are allocated on heap,managed by garbage collector.
if reference type contains value type as a member,where does meomory allocated for value types?
eg: class employee
{
int i; //stack or heap? or some boxing?
}
2.Value types are initialized to zero or null. does reference type member variables are initialized to zero or null?
Thanks
Viny.
|
|
|
|
|
vchedalla wrote:
if reference type contains value type as a member,where does meomory allocated for value types?
On the heap with the rest of the reference type.
The idea that value types are always created on the stack is not correct. If you have a method that creates a value type as part of its operation then it will be created on the stack, when the method ends it will be removed from the stack, along with everything else that was created on the stack during the method - and that includes any references to objects (NOTE: not the actual object - that will be done by the garbage collector if there are no other references to the object)
When a value type is a member variable of an object then it will be placed on the heap as it would not be logical to put it on the stack. A stack, as the name suggests, is built up as values are placed on it, and brought down as they are removed. You cannot remove a value from the middle of the stack.
vchedalla wrote:
Value types are initialized to zero or null. does reference type member variables are initialized to zero or null?
Value types cannot be initialised to null, but they can be initialised to some default value (like 0). Reference types are initialised to null.
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
i have a remote control, whose sensor is attached to the serial port. I would like to know how to use the serial port in .NET so i can create custom applications for the remote....
|
|
|
|
|
|
myCommand = new SqlCommand("INSERT INTO CES VALUES('"+(textBox1.Text)+"',"+
(textBox2.Text)+",'"+
(textBox3.Text)+"',"+
(textBox4.Text)+",'"+
(textBox5.Text)+
"','"+(textBox6.Text)+"','"+
(comboBox1.Text)+"',"+
(comboBox2.Text)+","+
(comboBox3.Text)+","+
(comboBox4.Text)+")"
,Form1.myConnection);
The problem is when I executed it , sometimes it throws an exception because of parameter missmatch...What I want is , I want to know which part of the command throws that exception.. Does anyone has any idea how to locate it?
Why I want is :
for example , if textBox1 has the problem the user can correct the wrong value of the field without entering all the values the other fields has..
|
|
|
|
|
The way you do it is just plain bad.
What if the user types in a value that contains an '??? It will crash right away. You need some validation. You should also make use of SqlParameter.
|
|
|
|
|
I have some validations...It is not the problem for me.. The code is just an example..
|
|
|
|
|
Ok.
Use SqlParameter, it is much more efficient than adding all the values to a string. It should solve your problem.
|
|
|
|
|
Then demonstrate how to do it the right way. Use the SqlParameter class. It'll take care of escaping the things that need to be, defend against a good number of SQL injection attacks and also makes it easier to find out where your problem is.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Tuğbay wrote:
I have some validations...It is not the problem for me..
You should use parameterised queries as a matter of course. Injecting values into a SQL String like this is not acceptable in today's security aware world.
See this article[^] which explains the security issues with the way you are doing this and gives an example of moving from this injection based way to using parameterised queries.
As a general bit of advice. If you are getting a syntax error and you need help on a forum you need to post the exact code that caused the syntax error and the syntax error itself. In this case you need to post the result of the string concatenations as it is quite difficult to tell from just the C# code alone.
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Ok , this time I think it is a logic error r smth... her eis the full code:
private void Tamam_Click(object sender, System.EventArgs e)
{
SqlCommand myCommand = null;
myCommand = new SqlCommand("INSERT INTO CES VALUES(@i_cesit,@i_uzunluk,@i_capı,@i_uzunlugu,@i_kavisi,@arayuz,@kod,@stok,@g_fiyat,@s_fiyat)",Form1.myConnection);
try
{
myCommand.Parameters.Add("@i_cesit",SqlDbType.VarChar);
myCommand.Parameters["@i_cesit"].Value = ıplık_cesıtı.Text;
myCommand.Parameters.Add("@i_uzunluk",SqlDbType.Int);
myCommand.Parameters["@i_uzunluk"].Value = ıplık_capı.Text;
myCommand.Parameters.Add("@i_capı",SqlDbType.VarChar);
myCommand.Parameters["@i_capı"].Value = ıplık_capı.Text;
myCommand.Parameters.Add("@i_uzunlugu",SqlDbType.Int);
myCommand.Parameters["@i_uzunlugu"].Value = (ıgne_uzunlugu.Text);
myCommand.Parameters.Add("@i_kavisi",SqlDbType.VarChar);
myCommand.Parameters["@i_kavisi"].Value = ıgne_kavısı.Text;
myCommand.Parameters.Add("@arayuz",SqlDbType.VarChar);
myCommand.Parameters["@arayuz"].Value = ara_yuzu.Text;
myCommand.Parameters.Add("@kod",SqlDbType.VarChar);
myCommand.Parameters["@kod"].Value = urun_kodu.Text;
myCommand.Parameters.Add("@stok",SqlDbType.Int);
myCommand.Parameters["@stok"].Value = (stok_mıktarı.Text).ToString();
myCommand.Parameters.Add("@g_fiyat",SqlDbType.Float);
myCommand.Parameters["@g_fiyat"].Value = (bırım_fıyatı.Text);
myCommand.Parameters.Add("@s_fiyat",SqlDbType.Float);
myCommand.Parameters["@s_fiyat"].Value =(bırım_fıyatı.Text); myCommand.ExecuteNonQuery();
}
catch (Exception a)
{
MessageBox.Show(a.ToString());
}
}
It keeps giving an error like :
"System.FormatException: Input string was not in a correct format.
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at CES.urun.Tamam_Click(Object sender, EventArgs e) in c:\documents and settings\şirin baba.aikanaro.002\desktop\ces\urun.cs:line 587"
o.k , what can be the problem , according to the articles found in net , there is nor mistake.. Has any one any idea?
Thanks a lot..
|
|
|
|
|
While I've never come across that error inside ExecuteNonQuery, I'm going to guess that the reason is because you have declared a parameter as one type and then passed a value of a different type. For example:
myCommand.Parameters.Add("@s_fiyat",SqlDbType.Float);
myCommand.Parameters["@s_fiyat"].Value =(bırım_fıyatı.Text);
Here you have declared the parameter @s_fiyat as a float, but then you pass a string as the actual value. You need to pass a float or double in that case.
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|