|
Luc Pattyn wrote: Please read
You are getting hopeful, Luc!
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."
|
|
|
|
|
Hopeful is not the word I would use, as I now get some people stating they agree with a little bit of my answer, as has happened here[^].
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.
|
|
|
|
|
It was the only bit that wasn't a question!
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."
|
|
|
|
|
When you make the call does the application actually create the registry entry at the location shown in the article at the link below; I.e. before you reboot, go and have a look at the registry and see if the file has been registered for deletion on reboot.
Also check the other registry setting that must be set to allow deletion of protected files (See very bottom of the article in the community content).
http://msdn.microsoft.com/en-us/library/aa365240(v=vs.85).aspx[^]
|
|
|
|
|
Hello,
Here is the answer for ur question... The following may help u well...
To have your C# (or any .NET program) run as Administrator in Windows, you'll have to create a manifest for it. What is a manifest file? I think Microsoft explains it best:
Every assembly, whether static or dynamic, contains a collection of data that describes how the elements in the assembly relate to each other. The assembly manifest contains this assembly metadata. An assembly manifest contains all the metadata needed to specify the assembly's version requirements and security identity, and all metadata needed to define the scope of the assembly and resolve references to resources and classes. The assembly manifest can be stored in either a PE file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a standalone PE file that contains only assembly manifest information. (link to the entire MSDN article)
With a Manifest you're able to tell Windows Vista that your C# program wants to run as Administrator. This will cause the Vista confirmation window to pop up asking the user to grant the program access. Running as Administrator in Vista is required, for example, if your program is trying to create a WCF endpoint.
The following manifest XML tells the .NET Framework to run the Assembly that you specify as Administrator within Windows Vista:
<?xml version="1.0" encoding="utf-8" ?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0"
processorArchitecture="X86"
name="someExecName"
type="win32" />
<description>Your Program Description</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"><security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" />
</requestedPrivileges>
</security>
</trustInfo></assembly>
add this manifest file to ur c# application as follows
Goto project-->properties-->add manifest file
and debug ur program then it works better...
Avinash...
|
|
|
|
|
Hi,
Is there any good and easy way to iterate through all the outcomes of recursion? Basically, I've a maze solver algorithm which solves maze instantly and prints the solved maze. I've broken down the code into each recursive call, and I need iterate to through it one by one..like if I press some button, then execution should stop at that point and maze state should be returned to main class and execution should proceed from the same point when I press some button. There is java applet on this website, I need to make one similar to it.
[^]
Any help would be appreciated.
Thanks,
Shivam Kalra
|
|
|
|
|
|
I know. Is there any way of implementing "yield" on your own?
|
|
|
|
|
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.
|
|
|
|