|
Well I'm working in a company environment... anything I do has to integrate with everything else. This is a super-large project. It takes Visual Studio literally 5 minutes to compile the site and all the DLLs and everything. I'm optimizing things, and I do have free reign on the code at the moment, but I do have to justify what I do sometimes.
I realize that the warnings don't prevent the thing from working, but they are not be ignored. One of my mentors always said "warnings are like a sign saying the bridge is out - it won't keep you from going down the road, but there's gonna be trouble eventually"
|
|
|
|
|
Hi,
I use #if false and #endif for hiding code.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Yes and no.
A switch statement with a return immediately before a break. The break is unreachable so is not compiled into IL.
|
|
|
|
|
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
No, there isn't - which I'm a bit surprised about. Makes no sense to include unreachable code I guess. Confirmed via Reflector/ildasm.
Regards,
Rob Philpott.
|
|
|
|
|
Just be sure it's not the result of conditional compilation. Though even then it should be written so as not to produce a warning.
|
|
|
|
|
Yes, our site originally had over 100 compiler warnings when you build. I consider that a Bad Thing. I've got it down to 23 at the moment, but I want to get it down to zero. Warnings are the computer telling you that something stupid is going on, not a broken something stupid, but still something stupid, and in most cases you just delete the thing, or code it a different way and it's functionally equivalent, but doesn't cause the warning. The break after a return statement is a good example... not having the break eliminates the warning, the break isn't necessary, and it's probably just there because somebody was told to put breaks in their switch/case blocks and was never told what it actually does.
|
|
|
|
|
Good Afternoon
I have been using vb.net am i recently moved to C# and thanks to codeProject am comming alright. now in vb.net we had Events ready generated for us on controls like button, when you double click on the button, on the right hand side you could select the events like "keypress", but vs on C# does nto have that.How is it done in C#, do i have to code the events myself?
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Not at all. Click the control in the designer to select it, press F4 (usually) for properties. Find the little lightning strike button, this shows you all the events on the control. Double click next to one to automatically insert the handler.
Regards,
Rob Philpott.
|
|
|
|
|
Thanks man
it works
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
You can double click on a control, like a button, and the default event, Click in this case, will be automatically created for you.
only two letters away from being an asset
|
|
|
|
|
Thank you very much
it works
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Say, I have 1000 different coordinate points which are totally scattered. Please give me some suggestions regarding how to find out the outer envelope area of those plotted points. Please provide me any link or sample project. Any suggestion on the algorithm would be helpful too.
Thanks in advance...
Faysal
|
|
|
|
|
Interesting problem. When you talk about the outer envelope - is this the smallest shape that contains all the points?
And when you say area - do you mean area (as measured in square centimetres say) or just the subset of points which define it?
Regards,
Rob Philpott.
|
|
|
|
|
|
Sorry, how is it related to the envelope area?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Because the envelope would be the shape bounded by the leaves of the tree.
|
|
|
|
|
What you want is the complex hull[^]
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
I am trying to add a database created in SQL Server Management Studio Express to a C# express application.
The data source is "Microsoft SQL Server Database File (SqlClient)"
The data provider is ".Net Framework data provider for SQL Server
I browse to the database and get a "The file is in use" error.
Visual C# 2008 Express Edition is the only application open.
What am I doing wrong?
Butch
|
|
|
|
|
Hi,
For developing a windows application that must work on a LAN, one way is common developing of it and sharing ConnectionString (i.e. ConnectionString be the IP address of Computer that SQL Server is installed on it).
Is there any other way? if yes, is it better?
Best wishes
|
|
|
|
|
Depends on what you want to do. If your application is a quick and dirty bodge and all the computers can access Sql Server direct on the LAN you can do this. You'd want to make sure you use Windows Authentication rather than SQL authentication mind for security reasons. I should stress it's not recommended on a quality basis though.
If you want to make a quality solution, you should look at abstracting the database away from the client computer by using an N-Tier architecture. http://en.wikipedia.org/wiki/Multitier_architecture[^]
Regards,
Rob Philpott.
|
|
|
|
|
Your question(s) made no sense.
|
|
|
|
|
I'm trying to set up a service with a class that make use of the FileSystemWatcher, is not working for some strange reason, basically I set up the FSW set an event handler and run the Service.
Now if I test the Class on a normal executable, once it passes through the FSW code the executable ends I had to put a while loop that will keep the executable running and that way it works perfectly, but the while loop takes too much processing when program is not doing anything, so I can't really put it on the service.
Another thing that I noticed when running the Service is that the event handler calls a method that actually calls an outside process but this process stays in memory and never gets out, I can see it in the task manager. The following code is the one I'm using for the Service:
class Watcher
{
const string DIRECTORY_TO_LISTEN = @"c:\tmp";
const string SFTP_SENDER = @"pscp.exe";
const string SFTP_SERVER = @"192.168.0.59";
const string SFTP_USER = "john";
const string SFTP_PASSWORD = "smith";
const string SFTP_LOCATION = @"/home/john/";
public bool ContinueRunning {get; set;}
public void Run()
{
try {
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = DIRECTORY_TO_LISTEN;
watcher.Created += new FileSystemEventHandler(OnFileCreated);
watcher.EnableRaisingEvents = true;
while (ContinueRunning)
{
System.Threading.Thread.Sleep(15000);
}
} catch (Exception ex) {
new Logger(ex.Message,"ezWatcher");//Logs Event viewer.
}
}
private void OnFileCreated(object source, FileSystemEventArgs e)
{
string output;
string args = String.Format("-sftp -pw {0} -batch {1} {2}@{3}:{4}{5}",
SFTP_PASSWORD,
e.FullPath,
SFTP_USER,
SFTP_SERVER,
SFTP_LOCATION,
e.Name);
Process proc = new Process();
try {
proc.EnableRaisingEvents = true;
proc.StartInfo.FileName = SFTP_SENDER;
proc.StartInfo.Arguments = args;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
output = proc.StandardOutput.ReadToEnd();
proc.WaitForExit();
proc_Exited(proc.ExitCode,e.Name,output);
} catch (Exception ex) {
new Logger(ex.Message, "SFTPWatcher");//Logs Event viewer.
}
}
private void proc_Exited(int result, string fileName, string output)
{
try {
new Logger(result + " " + fileName + " " + output, "ezWatcher");
SqlConnection conn =
new SqlConnection("Data Source=someServer;Initial Catalog=someDB;Persist Security Info=True;User ID=someUser;Password=somePass");
string query = String.Format("INSERT INTO SFTPWatcher SELECT [filename] = '{0}', [output] = '{1}', [result] = '{2}'", fileName, output, result.ToString());
SqlCommand cmd = new SqlCommand(query, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
} catch (Exception ex) {
new Logger(ex.ToString(), "SFTPWatcher"); //Logs Event viewer.
}
}
The calling code is:
protected override void OnStart(string[] args)
{
base.OnStart(args);
Thread process;
Watcher watch = new Watcher();
watch.ContinueRunning = true;
process = new Thread(new ThreadStart(watch.Run));
process.Start();
}
So if anyone show light on this will be appreciated.
Thank you.
|
|
|
|
|
Hi ,
i am able to create static crystal reports , but i want to create reports based on user input. I have to provide UI to select between two dates and some other options .
i want to get data from databse (sql 2005) based on these query ...
can any one suggest me how can i do : this (samples or Links )
Thanks
csn.
|
|
|
|
|
That thing will depend upon the version of Crystal Report you are using. In Crystal report 11, the method is, go to "Field Explorer". you have the option "Parameter Fields". Create a new parameter with datatype date time. for eg. "Startdate" & "EndDate". Now go to menu Report --> Select Expert. It will ask you to select the field. Assuming that the field you have to use is "DateofBirth", select this field.
Now a window will open & it will ask you for selecting a option, as for date, you will select "is between", then it will ask you the two values. Select the parameter field you have created earlier & click ok its done. Now see the preview it will ask you for input parameters.
Good luck
|
|
|
|