|
'image_editor.Form1.ComplementImages(System.Drawing.Image)': not all code paths return a value'
Can someone tell me whats the error in this code................
|
|
|
|
|
like this :
public bool DoIt(int input)
{
if (input == 0)
{
return true
}
}
All possible paths should have a return value
|
|
|
|
|
djsproject wrote: error in this code
Sorry, but where is your code?
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
|
How many columns do you have in this table called Marks?
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
thank you for your reply
i got the answer after sometime.
thanks
|
|
|
|
|
Hi guyz.. Im still on my project as the final touch up i have a task to be added to my project.. As i have mentioned in my previous post my project is on console application.. Thank you 2 all in code project because from the help and advice that i got from everyone at code project i was able 2 completed 90% of my project.. now the issue in my project it that my project migrates all the records stored in xml to the database its fine with it, certain records in the xml file are stored in another file in xml my application catches the file exactly and inserts the records from it. now i have a verification coded in my application which checks whether that particular file is present in the folder, if the file is present the records from it are migrated if the file is not present, on the output window it displays the name of the file stating that the file is missing in the folder.. now since my application has nested for loops and if condition the verification for the same file takes place more than once so in the output window the same missing file name is printed more than one(may be 10times) it becomes messy 2 see the output window..
Now what i would try to implement is that even if it checks the same file for the second time and if the file is not present it should display the message on the output window only one.. my coding is as follows:
class Class1
{
XmlDataDocument doc1 = new XmlDataDocument();
doc1.Load(ConfigurationSettings.AppSettings["fun"]);
XmlNodeList nodes1 = doc1.GetElementsByTagName("Row");
foreach(XmlNode node1 in nodes1)
{
if(node1.HasChildNodes && node1.ChildNodes.Count > 0)
{
XmlElement Element1 = (XmlElement) node1;
string f_ID = Element1.GetElementsByTagName("Id")[0].InnerText;
string f_AppId = Element1.GetElementsByTagName("AppId")[0].InnerText;
string f_FileName = Element1.GetElementsByTagName("FileName")[0].InnerText;
if(f_AppId==app)
{
string path = ConfigurationSettings.AppSettings["funfile"]+"\\"+f_FileName+".xml";
if (File.Exists(path))
{
XmlDataDocument doc2 = new XmlDataDocument();
doc2.Load(ConfigurationSettings.AppSettings["funfile"]+"\\"+f_FileName+".xml");
XmlNodeList nodes2 = doc2.GetElementsByTagName("Function");
foreach(XmlNode node2 in nodes2)
{
if(node2.HasChildNodes && node2.ChildNodes.Count > 0)
{
XmlElement Element2 = (XmlElement) node2;
string ff_Id = Element2.GetElementsByTagName("Id")[0].InnerText;
string ff_Url = Element2.GetElementsByTagName("Url")[0].InnerText;
string ff_AppId = Element2.GetElementsByTagName("AppId")[0].InnerText;
string ff_Status = Element2.GetElementsByTagName("Status")[0].InnerText;
if(f_ID==ff_Id && f_AppId==ff_AppId)
{
if(ff_Status=="Active" || ff_Status=="A" || ff_Status=="P")
{
cmd = new OdbcCommand("insert into EACS_Function_1 values('"+ff_Id+"','"+ff_FunctionDescription+"','"+ff_Url+"','"+ff_AppId+"','"+ff_Type+"','"+ff_MenuCommand+"','A','','','')",con);
cmd.ExecuteNonQuery();
}
}
else
{
Console.WriteLine("Please check Function file-{0} fields do not match",f_FileName);
}
}
}
}
else
{
Console.WriteLine("Function file {0} not present",f_FileName);
}
}
}
}
This is only a part of my coding.. My application has 860 lines of code.. so just imagine that how long my coding will be.. so plz advice me, when the for loop is traversed again and again the same missing file name is displayed on the screen which i have to aviod.. plz guide me..
Thanx in advance..
Regards,
Tash
|
|
|
|
|
One simple approach could be to create a bool variable called isPrinted and set it to false before your looping begins. When you reach a statement that will print a message saying that the file doesn't exist - check if the isPrinted is true . If not, then print your message and set isPrinted = true . The next time you reach the print statement your message will not print.
I didn't read your code very thorough, but it seems to me that you might want to change your design if you run into these kind of problems. Take a minute to think about it. Good luck!
|
|
|
|
|
thanx for ur reply... but that boolean function wont work in my condition because i have more that 5000 files and about 300 files are missing.. Ur case wil work if i have only one file which is missing... i think u got my point...
Regards,
Tash
|
|
|
|
|
Hello,
You could hold your outputed filenames in a list and make a lookup in the list bevor you do the next output.
Like this (using a generic List):
List<string> fileNames = new List<string>();
string f_FileName = ...;
...
if (!fileNames.Contains(f_FileName))
{
fileNames.Add(f_FileName);
Console.WriteLine("Please check Function file-{0} fields do not match", f_FileName);
}
Hope it helps!
All the best,
Martin
|
|
|
|
|
thanx but genericlist can be used in Dotnet framework 2.0 but im using VS2003 on framework 1.0 .. can i make use of array.. but the problem is i am not very much strong in arrays.. Do please guide me...
Thanx in advance..
Regards,
Tash
|
|
|
|
|
Hello,
<<thashif>> wrote: thanx but genericlist can be used in Dotnet framework 2.0 but im using VS2003 on framework 1.0
that's true!
<<thashif>> wrote: can i make use of array.. but the problem is i am not very much strong in arrays.. Do please guide me.
Sure!
instead of generics, you could use the StringCollection class, which is available in .Net 1.x:
using System.Collections.Specialized;
...
StringCollection fileNames = new StringCollection();
StringCollection , does also provide a Contains and a Add method, like the generic list.
Hope it helps!
All the best,
Martin
|
|
|
|
|
Hurray!!! it worked.... Thank u.. Million thanx.. Now my application is fully finished one.. once again thank you buddy...
Regards,
Tash
|
|
|
|
|
<<thashif>> wrote: Hurray!!! it worked.... Thank u.. Million thanx.. Now my application is fully finished one.. once again thank you
Wow, I'm really glad I could help!
All the best,
Martin
|
|
|
|
|
Hello again!
Apart from the solution I provided, I would like you to know, that you should take care about the ressources used by the OdbcCommand instances.
<<thashif>> wrote: cmd = new OdbcCommand...
Here you are instanciating allways a new OdbcCommand in a nested loop, and do not care about the ressources.
The OdbcCommand[^] derives from System.ComponentModel.Component[^], which does not implement IDisposable but provides a Dispose[^] method, you should call (cmd.Dispose(); ).
All the best,
Martin
|
|
|
|
|
Thanx for ur reply... as i have already mentioned my application is too big to post the complete code over here....
Martin# wrote: you should call (cmd.Dispose();).
i have a finally block which is as follows:
finally
{
if (rdr != null)
{
rdr.Close();
}
if (con != null)
{
con.Close();
con.Dispose();
}
cmd.Dispose
}
Thanx for ur advice i really appreciate it...
Regards,
Tash
|
|
|
|
|
sorry sorry i thought u were speaking abt the connection obj... okay fine i will take up ur advice of using
cmd.Dispose();
Thanx alot..
Regards,
Tash
|
|
|
|
|
<<tash18>> wrote: okay fine i will take up ur advice of using
cmd.Dispose();
All the best,
Martin
|
|
|
|
|
i want to use registry function for my remote desktop server, how to created registry function, for execute the server
from startup windows??
thanks for attention, i really need the answer urgently...
|
|
|
|
|
I'm not sure I understand your question.. Could you please elaborate?
|
|
|
|
|
how to make a software is run automatic, when windows start up.. using c#
|
|
|
|
|
Enter the path to a string value in this key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
|
|
|
|
|
how about the source code? is it need a additional variable?
how about the variable?, could you give the example(for visual C#)?
ok thanks.. GBu
|
|
|
|
|
All right.. Here's an example that will make Calculator autostart everytime you log on Windows.
using System;
using System.Text;
using Microsoft.Win32;
namespace AutostartCalc
{
class Program
{
static void Main(string[] args)
{
RegistryKey rKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
rKey.SetValue("Calculator", "\"C:\\Windows\\system32\\calc.exe\"");
rKey.Close();
Console.WriteLine("Added calculator to automatic startup. Press any key to continue...");
Console.ReadKey();
}
}
}
You should be able to figure out your own solution by looking at this. Good luck!
|
|
|
|
|
thanks, that is for console programing, do you have other example for desktop programing, or just is it that you have?
|
|
|
|