if someone could help me identify the problem please. [modified]
-
Here is my Code
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Data.Odbc;
using My;
using System.Data;namespace FirstCitizensBank_DropOffReport
{
class Program : MyGeneral
{
public static string dataBasePath;
public static string dbname;
public static string strconn;
static void Main(string[] args)
{
StartUp("", "", true);
dataBasePath = ConfigPath + "Empathic\\FirstCit\\";
dbname = "Bank";
strconn = "";try { string repname = dataBasePath + "Reports\\\\Dropoff" + myDate.ToString("yyyyMMdd") + ".xls"; DateTime enddate = myDate.AddDays(-myDate.Day); DateTime startdate = enddate.AddDays(1).AddMonths(-1); MyWriteExcel exl = new MyWriteExcel(repname, dataBasePath + "Reports\\\\Templates\\\\DropoffTemp.xls"); //dbname = dbname + myDate.ToString("yyMM"); //WriteMonth(ref exl, startdate, enddate, "B"); enddate = startdate.AddDays(-1); //startdate = startdate.AddMonths(-1); dbname = "Bank"; dbname = dbname + myDate.AddMonths(-1).ToString("yyMM"); WriteMonth(ref exl, startdate, enddate, "C"); enddate = startdate.AddDays(-1); startdate = startdate.AddMonths(-2); dbname = "Bank"; dbname = dbname + myDate.AddMonths(-2).ToString("yyMM"); WriteMonth(ref exl, startdate, enddate, "D"); exl.Save(); exl.Close(); MyEmail email = new MyEmail("", "First Citizens Bank Dropoff Report", "Please see attached report"); email.AddAttachment(repname); email.AddBCC(CommonEmail); email.sendEmail(); endProgram(); } catch (Exception e) { WriteToLog("@Failed: " + e.ToString()); HelpPage(e.ToString(), "Failed"); } } public static void WriteMonth(ref MyWriteExcel exl, DateTime startdate, DateTime enddate, string column) { string sql = "select count(\*) as total, sum(iif(mid(CALLSTATUS, 1, 2) >= '06', 1, 0)) as entered, sum(iif(DONE is not null, 1, 0)) as completed" + " from " + dbname + " where startdate
whwen comparing two strings, you should use the
s1.Equals(s2)
. The code
s1 == s2
just returns true if they are the same object not the same value.
Panic, Chaos, Destruction. My work here is done.
-
whwen comparing two strings, you should use the
s1.Equals(s2)
. The code
s1 == s2
just returns true if they are the same object not the same value.
Panic, Chaos, Destruction. My work here is done.
Where does it say that? Do you have proof? Why do people still believe this? :wtf: P.S. See: http://msdn.microsoft.com/en-us/library/system.string.op_equality(VS.71).aspx[^] " This operator is implemented using the Equals method, which means the comparands are tested for a combination of reference and value equality. The comparison is case-sensitive. " Therefore
==
==Equals
! -
whwen comparing two strings, you should use the
s1.Equals(s2)
. The code
s1 == s2
just returns true if they are the same object not the same value.
Panic, Chaos, Destruction. My work here is done.
Aren't all strings "interned" in .NET, i.e. two strings holding the same value actually point to a single instance? [EDIT] No, they are not (see this little article[^]). However,
string1==string2
andstring.Equals(string1,string2)
both call the string.Equals method and generate the correct result no matter what. [/EDIT] :)Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
modified on Friday, September 4, 2009 1:02 PM
-
Where does it say that? Do you have proof? Why do people still believe this? :wtf: P.S. See: http://msdn.microsoft.com/en-us/library/system.string.op_equality(VS.71).aspx[^] " This operator is implemented using the Equals method, which means the comparands are tested for a combination of reference and value equality. The comparison is case-sensitive. " Therefore
==
==Equals
!I was sure that it was the case. I have just chickened and according to Troelsen, == and .equals both compare content. :-O I think it's wrong, but going by what Luc says below it makes some sort of sense. I have java as well as C#, there it is absolutly == comnpares references and .equals() compares values.
Panic, Chaos, Destruction. My work here is done.
-
Aren't all strings "interned" in .NET, i.e. two strings holding the same value actually point to a single instance? [EDIT] No, they are not (see this little article[^]). However,
string1==string2
andstring.Equals(string1,string2)
both call the string.Equals method and generate the correct result no matter what. [/EDIT] :)Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
modified on Friday, September 4, 2009 1:02 PM
head is bowed.
Panic, Chaos, Destruction. My work here is done.
-
I was sure that it was the case. I have just chickened and according to Troelsen, == and .equals both compare content. :-O I think it's wrong, but going by what Luc says below it makes some sort of sense. I have java as well as C#, there it is absolutly == comnpares references and .equals() compares values.
Panic, Chaos, Destruction. My work here is done.
Well .net is better than Java. (duh!) :-D
-
Here is my Code
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Data.Odbc;
using My;
using System.Data;namespace FirstCitizensBank_DropOffReport
{
class Program : MyGeneral
{
public static string dataBasePath;
public static string dbname;
public static string strconn;
static void Main(string[] args)
{
StartUp("", "", true);
dataBasePath = ConfigPath + "Empathic\\FirstCit\\";
dbname = "Bank";
strconn = "";try { string repname = dataBasePath + "Reports\\\\Dropoff" + myDate.ToString("yyyyMMdd") + ".xls"; DateTime enddate = myDate.AddDays(-myDate.Day); DateTime startdate = enddate.AddDays(1).AddMonths(-1); MyWriteExcel exl = new MyWriteExcel(repname, dataBasePath + "Reports\\\\Templates\\\\DropoffTemp.xls"); //dbname = dbname + myDate.ToString("yyMM"); //WriteMonth(ref exl, startdate, enddate, "B"); enddate = startdate.AddDays(-1); //startdate = startdate.AddMonths(-1); dbname = "Bank"; dbname = dbname + myDate.AddMonths(-1).ToString("yyMM"); WriteMonth(ref exl, startdate, enddate, "C"); enddate = startdate.AddDays(-1); startdate = startdate.AddMonths(-2); dbname = "Bank"; dbname = dbname + myDate.AddMonths(-2).ToString("yyMM"); WriteMonth(ref exl, startdate, enddate, "D"); exl.Save(); exl.Close(); MyEmail email = new MyEmail("", "First Citizens Bank Dropoff Report", "Please see attached report"); email.AddAttachment(repname); email.AddBCC(CommonEmail); email.sendEmail(); endProgram(); } catch (Exception e) { WriteToLog("@Failed: " + e.ToString()); HelpPage(e.ToString(), "Failed"); } } public static void WriteMonth(ref MyWriteExcel exl, DateTime startdate, DateTime enddate, string column) { string sql = "select count(\*) as total, sum(iif(mid(CALLSTATUS, 1, 2) >= '06', 1, 0)) as entered, sum(iif(DONE is not null, 1, 0)) as completed" + " from " + dbname + " where startdate
Dunno, step through it with the debugger and see what's actually happening.
-
whwen comparing two strings, you should use the
s1.Equals(s2)
. The code
s1 == s2
just returns true if they are the same object not the same value.
Panic, Chaos, Destruction. My work here is done.
Ummm .... they both work. Case in point;
static void Main(string\[\] args) { string strTest1 = "This is a test"; string strTest2 = "This is a second test"; Console.WriteLine("strTest1 == strTest2 : {0}", strTest1 == strTest2); Console.WriteLine("strTest1 == \\"This is a test\\" : {0}", strTest1 == "This is a test"); Console.WriteLine("strTest1.Equals(strTest2) : {0}", strTest1.Equals(strTest2)); Console.WriteLine("strTest1.Equals(\\"This is a test\\") : {0}", strTest1.Equals("This is a test")); Console.ReadLine(); }
output
strTest1 == strTest2 : False
strTest1 == "This is a test" : True
strTest1.Equals(strTest2) : False
strTest1.Equals("This is a test") : TrueIf at first you don't succeed ... post it on The Code Project and Pray.
-
Here is my Code
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Data.Odbc;
using My;
using System.Data;namespace FirstCitizensBank_DropOffReport
{
class Program : MyGeneral
{
public static string dataBasePath;
public static string dbname;
public static string strconn;
static void Main(string[] args)
{
StartUp("", "", true);
dataBasePath = ConfigPath + "Empathic\\FirstCit\\";
dbname = "Bank";
strconn = "";try { string repname = dataBasePath + "Reports\\\\Dropoff" + myDate.ToString("yyyyMMdd") + ".xls"; DateTime enddate = myDate.AddDays(-myDate.Day); DateTime startdate = enddate.AddDays(1).AddMonths(-1); MyWriteExcel exl = new MyWriteExcel(repname, dataBasePath + "Reports\\\\Templates\\\\DropoffTemp.xls"); //dbname = dbname + myDate.ToString("yyMM"); //WriteMonth(ref exl, startdate, enddate, "B"); enddate = startdate.AddDays(-1); //startdate = startdate.AddMonths(-1); dbname = "Bank"; dbname = dbname + myDate.AddMonths(-1).ToString("yyMM"); WriteMonth(ref exl, startdate, enddate, "C"); enddate = startdate.AddDays(-1); startdate = startdate.AddMonths(-2); dbname = "Bank"; dbname = dbname + myDate.AddMonths(-2).ToString("yyMM"); WriteMonth(ref exl, startdate, enddate, "D"); exl.Save(); exl.Close(); MyEmail email = new MyEmail("", "First Citizens Bank Dropoff Report", "Please see attached report"); email.AddAttachment(repname); email.AddBCC(CommonEmail); email.sendEmail(); endProgram(); } catch (Exception e) { WriteToLog("@Failed: " + e.ToString()); HelpPage(e.ToString(), "Failed"); } } public static void WriteMonth(ref MyWriteExcel exl, DateTime startdate, DateTime enddate, string column) { string sql = "select count(\*) as total, sum(iif(mid(CALLSTATUS, 1, 2) >= '06', 1, 0)) as entered, sum(iif(DONE is not null, 1, 0)) as completed" + " from " + dbname + " where startdate
I have solved this problem and appreciate all the reply's. The problem was that if a call status came back that wasn't in one of my if statements the program was defaulting to the last line number used since i am not increamenting line numbers. I am sure this is a rookie mistake and i thank you.
-
Where does it say that? Do you have proof? Why do people still believe this? :wtf: P.S. See: http://msdn.microsoft.com/en-us/library/system.string.op_equality(VS.71).aspx[^] " This operator is implemented using the Equals method, which means the comparands are tested for a combination of reference and value equality. The comparison is case-sensitive. " Therefore
==
==Equals
!PIEBALDconsult wrote:
Therefore == == Equals !
:cool:
-
I have solved this problem and appreciate all the reply's. The problem was that if a call status came back that wasn't in one of my if statements the program was defaulting to the last line number used since i am not increamenting line numbers. I am sure this is a rookie mistake and i thank you.
Yeah, see? Use a
switch
instead. -
Aren't all strings "interned" in .NET, i.e. two strings holding the same value actually point to a single instance? [EDIT] No, they are not (see this little article[^]). However,
string1==string2
andstring.Equals(string1,string2)
both call the string.Equals method and generate the correct result no matter what. [/EDIT] :)Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
modified on Friday, September 4, 2009 1:02 PM
Depending on your point of view, fortunately or unfortunately, not all strings in the CLI are interned. Essentially, any string loaded with the MSIL ldstr command is interned, and anything programatically interned is interned. For example, if we run the following code
string interned1 = "hello";
string interned2 = "hello";
string notinterned = new String("hello".ToCharArray());
string interned4 = string.Intern(notinterned);
Console.WriteLine(RuntimeHelpers.GetHashCode(interned1));
Console.WriteLine(RuntimeHelpers.GetHashCode(interned2));
Console.WriteLine(RuntimeHelpers.GetHashCode(notinterned));
Console.WriteLine(RuntimeHelpers.GetHashCode(interned4));then we get the corresponding output
58225482
58225482
54267293
58225482As you can see from the output, the interned strings all show the same "memory location" while the programatically constructed string shows a different location. (.NET 3.5) In terms of string equality, though, the override of operator== calls the public static string.Equals(string, string) method which calls a private static method to determine equality. string.Equals(string) calls the private static method directly.
"we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty
-
whwen comparing two strings, you should use the
s1.Equals(s2)
. The code
s1 == s2
just returns true if they are the same object not the same value.
Panic, Chaos, Destruction. My work here is done.
Hi Nagy,
Nagy Vilmos wrote:
s1 == s2 just returns true if they are the same object
as others already told you, this is completely wrong. I did some investigation, triggered both by this thread and by the lean-and-mean competition, and that resulted in this little article of mine[^]. :)
Luc Pattyn
:badger: :jig: :badger:
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
:jig: :badger: :jig: