|
yes, you could do what the compiler does with yield , i.e. save and restore the entire state of the locals of all the nesting levels; it easily becomes quite cumbersome and I can't recommend it.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Alright. Thanks!
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
hi,
I can access what i need with this code in sql management studio Select SUM(total) From Income Where MonthName = 'February'
but can't do the same from c#. Thanks in advance
|
|
|
|
|
so?
are you the first person to have some difficulty with a database?
would you know of a site that holds some very relevant articles?
maybe you could use a search engine and get some suggestions?
BTW: I don't think storing months as strings is a great idea anyway.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
What have you tried? Show us your C# code and explain where it isn't working.
BTW: I agree with Luc on the "months as strings" bit: change them to a DateTime if you can. Consider this: every year has a "February" - do you want to sum last years in with this years?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
I just changed the table names in my first question, in fact I don't hold months as nchar.
Below is what I tried. All I want is to get the sum of rows where MasaNo column value is "Gelir". I always check web before asking you.But eventhough I've done the suggested, no success
//one with parameters
string commandText = "Select SUM(Hesap) From Gecmis Where MasaNo = @MasaNo";
SqlCommand cmdGelir = new SqlCommand(commandText, sqlBaglanti);
cmdGelir.Parameters.Add("@MasaNo", SqlDbType.NChar);
cmdGelir.Parameters["@MasaNo"].Value = "Gelir";
//And this one
SqlCommand cmdGelir = new SqlCommand("Select SUM(Hesap) From Gecmis Where MasaNo = 'Gelir'", sqlBaglanti);
|
|
|
|
|
If this is all of the code that performs the query, then you're missing the command that actually launches the query. Did you see the ExecuteScalar[^] method of the SqlCommand object?
|
|
|
|
|
If you don't hold the months as nchar, what do you hold them as? Since you always test them against a string value (assuming as Dave says that you execute your query - I assume you do), you have to be storing them as a string of some kind.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Hi, sorry making things complicated. I should have given the entire code for sqlcommand at the beginning but thought I could explain my problem in the shortest way not to bother you. Regarding to your question, Yes I use ExecuteScalar() as below.
float diger = 0F;
SqlCommand cmdGelir = new SqlCommand("Select SUM(Hesap) From Gecmis Where MasaNo = 'Gelir'", sqlBaglanti);
if (cmdGelir.ExecuteScalar().ToString() != "0" && cmdGelir.ExecuteScalar().ToString() != "") diger = float.Parse(cmd.ExecuteScalar().ToString().Trim());
Is it the apostrophes around Gelir? Because the same command works well in management studio
|
|
|
|
|
Oh dear, oh dear. Please don't do that!
float diger = 0F;
SqlCommand cmdGelir = new SqlCommand("Select SUM(Hesap) From Gecmis Where MasaNo = 'Gelir'", sqlBaglanti);
diger = (float) cmdGelir.ExecuteScalar(); Does exactly the same thing without:
Two extra database accesses
Three unnecessary int-to-string conversions
One unnecessary Trim operation (with the output guaranteed to equal the input)
One unnecessary Parse operation
Six unneccessary string creations!
And probably a Partridge in a Pear Tree!
I ask again: what is the field definition of "MasaNo"?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
OriginalGriff wrote: I ask again: what is the field definition of "MasaNo"?
MasaNo is a nchar column and no primary key defined
|
|
|
|
|
What does "is not working" mean - an error or not the expected result? Since you are working with nchar and Turkish words, are you sure you set all the settings correctly for your connection, use the correct culture on both server and client, etc?
Is "gecmis" missing diacritic characters? I suggest to avoid non-English names for tables and columns (or at least use ASCII characters without spaces only for their names), it causes too many problems. The data to be stored may have localized content, that's something different, but also not absolutely trouble-free.
|
|
|
|
|
Bernhard Hiller wrote: What does "is not working" mean
It is working but it returns the sum of all rows. But in management studio, it brings the sum of MasaNo column with values 'Gelir'
By the way,to make it more understandable, MasaNo means TableNo and Gelir means Income.
|
|
|
|
|
That's extremely strange. Could you try
SqlCommand cmdGelir = new SqlCommand("Select SUM(Hesap), MasaNo From Gecmis Where MasaNo = 'Gelir' Group By MasaNo", sqlBaglanti);
Then loop through all the rows returned. This might help to get closer to the source of the problem. It should be exactly one row. If it is more, look at there MasaNo values...
And another point: sometimes the use of two different systems for accessing databases can cause confusion - are you sure you connect to the same database?
|
|
|
|
|
Thanks for your interest, I solved it finally.
|
|
|
|
|
this might be a very simple question but i tried to change the visibility of a label with in
a timer ticker event. here is the code segment
private void timer1_Tick(object sender, EventArgs e)
{
label1.Visible = false;
Thread.Sleep(2000);
label1.Visible = true;
}
timer interval is set to 1000 and enabled.
but the visibility is not working. once it is disappeared it doesn't show again.
any idea why this happens.
|
|
|
|
|
Think about it for a moment.
You are firing the timer every 1000 ms. When it fires you are telling the thread to sleep for 2000 ms, so if the Visible = true line fires it fires while the thread is asleep and so you will not see the effect. Next time the timer fires it makes the label invisible then sleeps again and the whole thing repeats indefinitely.
Try setting Thread.Sleep(500) (or any value less than your timer interval).
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
|
|
|
|
|
Since you are manipulating GUI components, this must be done on the GUI thread, so your timer has to be a Windows.Forms.Timer ; however it does not make sense to have a Thread.Sleep() in code that executes on the GUI thread, as that would freeze the GUI (or not work at all).
You should implement a state machine, that changes state in the Tick handler without waiting at all. Example: if you want a 5Hz blinking label, set the timer interval to 100, and do:
private void timer1_Tick(object sender, EventArgs e) {
label1.Visible = !label1.Visible;
}
In the example, the state machine is pretty much hidden as all the state is in the label's visibility itself.
Remember: only use Thread.Sleep() in threads other than the GUI thread. And most often it is better not to use it at all.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hello,
I been working on outlook, from few days. I could able to delete all items from Deleted items folder. But the memory remains same for PST file. I know how to compact(compress) the PST file manually.. Could any one guide me around how to implement this through an Applications.
Any references and samples highly appreciated.....
Thanks in advance....
|
|
|
|
|
I don't think there is an API to do that. It's not exposed at all.
Best wishes,
Navaneeth
|
|
|
|
|
Hi,
I want to send sms from my pc to mobile through AT commands. I have sonny ericsson k310i and Samsung Gtb 3210. Does any one of this support AT commands in text mode??
Thanks in advance.
Regards,
Aeman
|
|
|
|
|
All GSM / GPRS mobiles should support it: there is a tutorial here[^] that should help.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Thanks. But i m not sure that some mobiles support only PDU mode not text mode.I m not getting the actual idea?
|
|
|
|
|
Hello Everybody,
I am receive information from Socket.And Now i want to filter and Get only URL.
int bytes = socket.Receive(buffer);
String str= Encoding.ASCII.GetString(buffer, 0, bytes);
So please help regarding this.
Thanks
If you can think then I Can.
|
|
|
|