|
Jamie1985 wrote: wever it says the value is not in the correct format.
any help?
Yes, obviously ensure Session["Qty_New"] has data, and that that data can be converted to an int before converting it.
Check out int.TryParse rather than Convert.ToInt32
|
|
|
|
|
Two things - you don't actually need to convert the session to an int to assign it to the parameter. Also, you should check to see if Session["Qty_New"] is null or an empty string before using it.
|
|
|
|
|
Hi
are you sure i dont need to convert to int, i took it out and left it like this
string Qty_New
Qty_New = tb_Qty_New.Text;
cmd.Parameters.Add(new SqlParameter("@qty_new", SqlDbType.Int));
cmd.Parameters["@qty_new"].Value = Qty_New;
however this doesnt work
there is a value in Qty_New
cheers
|
|
|
|
|
Any leading/trailing space character in that?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
no just a one digit number in the text box value
|
|
|
|
|
fixed it
the textbox value was set on page_load instead of the onlclick
thanks
|
|
|
|
|
Hi all,
I want to sending an XML string using webservice installed at server to the client using IP(internet IP) and then further want to save it in the from of XML file.
can anybody tell me how to do it???
Thanks in advance.
Ankur
|
|
|
|
|
can we hide focus from grid cell
amit
|
|
|
|
|
|
how do i redirect to anther page when i only know the path of the libery?
|
|
|
|
|
Your post doesn't make much sense. Redirect what?
wrote: when i only know the path of the libery?
Is not clear at all.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
how to deactivate grid cell if it is active.
amit
|
|
|
|
|
I want to know what is happening in these lines of code:
a)
public class cAppBarDisplay:AppBar
{
cMessageProcessing CMS;
public cAppBarDisplay(cMessageProcessing cMP)
{
CMS = cMP;
}
}
->cMessageProcessing CMS;
By this mean are we creating a refrence?
->and what the constructer is actually doing?
CMS & cMP both are refrence of same class
Thanks in advance,
plz describe in a bit detail.
|
|
|
|
|
humdumof wrote: ->cMessageProcessing CMS;
By this mean are we creating a refrence?
You created a field called CMS, which you can set to reference an instance of cMessageProcessing. This happens when you do CMS = cMP for example.
humdumof wrote: CMS = cMP;//exactly what is happening here
You assign the parameter cMP to the field CMS. They now hold the same reference to an instance of the cMessageProcessing class (not a reference to the class itself).
|
|
|
|
|
AlwiNus wrote: You assign the parameter cMP to the field CMS. They now hold the same reference to an instance of the cMessageProcessing class (not a reference to the class itself).
Not a refrence to the class itself?
By this what u mean?
also CMS=cMP;
Does it mean we can access all the methods of cMessageProcessing thru CMS?
& what is use of doing all this in constructor?
|
|
|
|
|
humdumof wrote: Not a refrence to the class itself?
By this what u mean?
When you use a class you create an instance of it. Kinda like if i want a bowl of cereal, i have to get myself a bowl and some cereal, and probably some milk. Then my bowl of cereal that i can eat, would be an instance of a bowl of cereal... if you follow me.
When you pass the instance of your class to the constructor your passing a reference (pointer) to it.
humdumof wrote: also CMS=cMP;
Does it mean we can access all the methods of cMessageProcessing thru CMS?
& what is use of doing all this in constructor?
Yes, you can access all the methods of the class through CMS.
The use of this, is that you can make use of the same instance of a class, in as many different classes as you like. So you can make 1 instance of your class, and pass it to 2 other classes for example. Then both classes will work on the same instance.
EDIT: As for why you should actually do this in the constructor: If the new class depends on having an instance of cMessageProcessing (ie it uses it) and it does not get passed a reference or create its own instance, then it will probably crash. By passing it to the constructor, you can guarantee that the new class will always have an instance of cMessageProcessing, it would be impossible to instatiate the class (ie myClass = new MyClass()) without passing the correct parameters.
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
buddy, U have a typical class code with u.
Just look in the code its just a constructor with one parameter which is initiallising the value passed by the parameter to the local class variable.
|
|
|
|
|
I am writing a program using System.Timers.Timer to trigger the webcam to capture an image and saved in a file.
The image saving function is workable when it works standalone (by clicking a button). However, when I call the image saving function in the OnTimedEvent (event-triggering function) it fails. It will pop up the following error message:
"System.NullReferenceException: Object reference not set to an instance of an object...."
I lately found that the Data could not be retrieved from the clipboard when the clipboard is being used by another process...
Following is the Caputure function of the webCam device... (in Device.cs)
public Image Capture()<br />
{<br />
try{<br />
if (deviceHandle != 0)<br />
{<br />
SendMessage(deviceHandle, WM_CAP_EDIT_COPY, 0, (IntPtr)0);<br />
IDataObject ido = Clipboard.GetDataObject();<br />
if (ido.GetDataPresent(DataFormats.Bitmap))<br />
{<br />
return ((Bitmap)ido.GetData(DataFormats.Bitmap));<br />
}<br />
}<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);<br />
}<br />
return null;<br />
<br />
}
Following is the timer triggering function...
private void OnTimedEvent(object source, ElapsedEventArgs e)<br />
{<br />
<br />
SavingOnePic(Directory.GetCurrentDirectory(), txtSavingName.Text.ToString());<br />
<br />
}
Following is the saving Function, it works when it is called from a button click event. however, does not work in the above OnTimedEvent function.
private void SavingOnePic(string savingPath, string fileName)<br />
{<br />
<br />
try<br />
{<br />
<br />
if (!Directory.Exists(@savingPath+@"\capturedImage")) <br />
{<br />
Directory.CreateDirectory(@savingPath + @"\capturedImage");<br />
fileIndex = 0;<br />
}else{<br />
string[] fileList = Directory.GetFiles(@savingPath + @"\capturedImage",<br />
fileName + "*.png");<br />
<br />
fileIndex = fileList.Length;<br />
}<br />
<br />
Image image = selectedDevice.Capture();<br />
<br />
image.Save(@savingPath + @"\capturedImage\" + fileName + <br />
"_000" + fileIndex.ToString() + ".png", ImageFormat.Png);<br />
<br />
fileIndex++;<br />
<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);<br />
}<br />
}
|
|
|
|
|
And the question is ...
SkyWalker
|
|
|
|
|
Sorry that I didn't mention it clearly.
I want to know why the SavingOnePic function in OnTimedEvent cannot run.
I found that the clipboard does not have any data if the SavingOnePic function in OnTimedEvent. But I don't know how to solve it
Thanks
|
|
|
|
|
You can try to use a System.Windows.Forms.Timer instead, which is tread-safe. If i remember it correctly the System.Timers.Timer isn't (not sure though).
Also, when you mention that you get an exception, it is more helpful if you post the full exception, including stack trace etc..
HTH
|
|
|
|
|
As you already said, there is no data of that type in your clipboard.
You cannot retrieve what does not exist
Therefore, you should avoid "calling" methods of non-existing methods:
IDataObject ido = Clipboard.GetDataObject();
if (ido != null)
{
}
else
{
return;
}
SkyWalker
|
|
|
|
|
Is it because System.timers.timer is not thread-safe, so no data can be retrieved from Clipboard. If it is the case, how can I make the System.timers.timer be thread-safe?
|
|
|
|
|
How do i apply regular expression to find for host name from the text below and it prints out Host name: IT786P20??
Host Name: IT786P20
OS Name: Microsoft Windows XP Professional
|
|
|
|
|
Hi
The question is if you really want to use a regular expression for this. wouldn't a string operation do the job?
someting like
string blah = @"Host Name: IT786P20
OS Name: Microsoft Windows XP Professional"
int colonIndex = blah.IndexOf(":");
string HostName = blah.SubString(colonIndex+1,blah.IndexOf("\r",colonIndex+1)-colonIndex+1).Trim();
Console.WriteLine(HostName);
btw. if you want to work with regular expressions i would recommend you to get expresso it's a free tool with a great regex-Builder and Tester.
here[^]
greets
m@u
|
|
|
|