Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.5
if (DtMain.ToString().Substring(0, 5) == drNameShow.GetString(3).Substring(0, 5))
                {
                    lblPname.Location = new Point(32, 2 + iLblSme);
                    objMain.panNameMain.Controls.Add(this.lblPname);
                    objMain.lblDate.Text = DtMain.ToString().Substring(0, 10);
                    iLblSme = iLblSme + 20;
                    boolSmeDay = true;
                }
it gives error as "Specified cast is not valid."
Posted 7-Aug-12 23:47pm
Edited 7-Aug-12 23:49pm
v2
Comments
Philip Stuyck at 8-Aug-12 5:52am
   
at what line. I don't see any casting here in this code. Your problem might be elsewhere.
16041984 at 8-Aug-12 5:59am
   
on if statement it gives error if (DtMain.ToString().Substring(0, 5) == drNameShow.GetString(3).Substring(0, 5)) plz help.i m newbie
16041984 at 8-Aug-12 5:54am
   
on if statement it gives error if (DtMain.ToString().Substring(0, 5) == drNameShow.GetString(3).Substring(0, 5))
Prabhakaran Soundarapandian at 8-Aug-12 5:54am
   
Which line you are getting error while debugging?
16041984 at 8-Aug-12 5:59am
   
on if statement it gives error if (DtMain.ToString().Substring(0, 5) == drNameShow.GetString(3).Substring(0, 5)) plz help.i m newbie

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

if drNameShow is datareader means try the below code.
 
string mystring = drNameShow["columnName"].ToString();
if (DtMain.ToString().Substring(0, 5) == mystring.Substring(0, 5))
  Permalink  
Comments
16041984 at 8-Aug-12 6:03am
   
it's working also i have error on code if ((DtAdv1.ToString().Substring(0, 5) == drNameShow.GetString(3).Substring(0, 5)) || (DtAdv2.ToString().Substring(0, 5) == drNameShow.GetString(3).Substring(0, 5))) {
Prabhakaran Soundarapandian at 8-Aug-12 6:09am
   
do the same like above what you did and compare..
16041984 at 8-Aug-12 6:16am
   
thx now it's working thx to Prabhakaran Soundarapandian sir
Prabhakaran Soundarapandian at 8-Aug-12 6:18am
   
Welcome!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 895
1 OriginalGriff 523
2 thatraja 245
3 Abhinav S 243
4 Emre Ataseven 200
0 Sergey Alexandrovich Kryukov 8,142
1 OriginalGriff 4,665
2 Peter Leow 3,774
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 8 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid