Showing posts with label message. Show all posts
Showing posts with label message. Show all posts

Wednesday, March 28, 2012

String was not recognized as a valid DateTime.

hi,

i just uploaded my web application to a remote server, everything works fine on my local machine..

but i m getting this error message on my remote server .. that is perhaps on the remote pc the sql server is handling datetime in a different format... how to check it and how can i set it up same as my local sql server date time format? or is there any other solution to it ?

String was not recognized as a valid DateTime.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.FormatException: String was not recognized as a valid DateTime.

in the database... column type is date time and and even this simple query is generating this error..

dim str as sqldatetime = sqldatetime.parse("Select 'datecolumn' from table")

thanks

Ok wich version of SQL server do u have on your pc and on your server?

That error might appear when you type a string in a wrong way

acepted formats in SQL SERVER EXPRESS 2005

01/01/2006

1/1/2006

1/1/06

1/01/06

1/01/2006

01/1/2006

01/1/06

I hope this helps


no, i m not inserting any date... when sumone gets registered to the system.. the stored procedure gets the date using function getdate() and i m just selecting it using .. a datareader and puting it in

sqlDateTime type variable... it is working perfectly in local pc.. that is sql server 2000 same is on the SERVER pcc... but i found one difference that in my pc it is storing date as mm/dd/yy and on server pc it is generating date using getdate() as yy/dd/mm... although did't change any settings....

and this format of yy/dd/mm is giving error when i retrieve it in variable sqlDateTime in asp.net!

even if i change its format in selection... then i wont work on my local pc.. because sql server on my local pc is generating date using getdate() as mm/dd/yy...

any help ?

thanks

string.format Problem

I am trying to fill in a summary in the footer of my grid view but I keep getting an error

Message="Format specifier was invalid."
make sure your method argumements are in the right format

lblsummary.Text = String.Format("Total hrs: {0:d}", hrtotalsTotal)

e.Row.Cells(2).Text = (hrtotalsTotal / 60).ToString(

"d")

I got this format from msdn what is causing this

Hi,

What is your hrtotalsTotal value?

From what I can see, you're trying to convert a double to DateTime presentation format... It does not make any sense. You should use TimeSpan object. And I think your hrtotalsTotal is actually a total number of minutes... anyways, try this:

Dim totalHoursAs Double = 3.4'3 hours 24 minutesDim tsAs TimeSpan = TimeSpan.FromHours(totalHours)Response.Write(ts.ToString())

hrtotalstotal is declared as a decimal and is the sum of a grid view col.

dim hrtotalstotal as decimal

I am just deviding hrstotalstotal/60 to get total hrs. in a decimal format ie 75 min = 1.15 hrs....

nothing to do with any dates or times.

e.Row.Cells(2).Text = (hrtotalsTotal / 60).ToString("d")


ok then.

My example should help you out on this.


Your format specifier is invalid becoz you have declared the variable as decimal and using the integer format specifier.

Try this

lblsummary.Text = String.Format("Total hrs: {0:f}", hrtotalsTotal)
e.Row.Cells(2).Text = (hrtotalsTotal / 60).ToString("f")

Thanks


where can I get a list of the format specifier

Check this linkhttp://blog.g9th.com/2007/01/29/string-formats-in-c.aspx

Thanks

Monday, March 26, 2012

StringBuilder AppendLine dont print Line breaks in my emails!

Hello... I'm working with StringBuilder to create a message to send via text email.

My methos is:

StringBuilder retorno = new StringBuilder();

retorno.AppendLine ( "A lot of text 1" );
retorno.AppendLine ( "A lot of text 2" );

return retorno.ToString() ;

Well.. I this last line I return the text to the message, but the email arrives without line breaks.

What can i do? thanks!

if you email format is in HTML, then you can use tag "<BR>" to create a line break

StringBuilder sb = new StringBuilder();
sb.Append("A lot of text 1");
sb.Append("<br>");
sb.Append("A lot of text 2);
return retorno.ToString() ;

else

you may try using \r\n, sb.Append("XXX\\r\\nXXXX");


have you tried for this one ?? it shoud work as it worked for me..

 StringBuilder retorno =new StringBuilder(); retorno.AppendLine("A lot of text 1"); retorno.AppendLine("<br />"); //....append a <br /> Tag... retorno.AppendLine("A lot of text 2"); Response.Write(retorno.ToString());

hope it helps./.

StringBuilder to Text

Hello, I a m building an email message in a StringBuilder Object and then
using the StringBuilder ToString() method to get it to regular text. It
appears to me that when I place a "\n" into the Stringbuilder object that
when this is translated into text, I loose the page break. Is this true and
I doing something wrong?
I'm guessing that I could insert a special character into the StringBuilder
object and then use the string Replace() method to translate that special
character into a "\n" and perhaps this would work.
Just wondering why it does not work when I place that value into the
StringBuilder Object.
ThanksHow are you noticing that you loose the break? In what context is this
happening?
"Jim Heavey" <JimHeavey@.discussions.microsoft.com> wrote in message
news:1BC14F11-5DBA-4865-9CFB-2881598EB955@.microsoft.com...
> Hello, I a m building an email message in a StringBuilder Object and then
> using the StringBuilder ToString() method to get it to regular text. It
> appears to me that when I place a "\n" into the Stringbuilder object that
> when this is translated into text, I loose the page break. Is this true
> and
> I doing something wrong?
> I'm guessing that I could insert a special character into the
> StringBuilder
> object and then use the string Replace() method to translate that special
> character into a "\n" and perhaps this would work.
> Just wondering why it does not work when I place that value into the
> StringBuilder Object.
> Thanks
Have you considered using Environment.Newline instead of "\n"?
Example:
StringBuilder textBuilder = new StringBuilder(512);
textBuilder.Append("Dear John,");
textBuilder.Append(Environment.Newline)
Perhaps that will help.
carl
"Jim Heavey" <JimHeavey@.discussions.microsoft.com> wrote in message
news:1BC14F11-5DBA-4865-9CFB-2881598EB955@.microsoft.com...
> Hello, I a m building an email message in a StringBuilder Object and then
> using the StringBuilder ToString() method to get it to regular text. It
> appears to me that when I place a "\n" into the Stringbuilder object that
> when this is translated into text, I loose the page break. Is this true
> and
> I doing something wrong?
> I'm guessing that I could insert a special character into the
> StringBuilder
> object and then use the string Replace() method to translate that special
> character into a "\n" and perhaps this would work.
> Just wondering why it does not work when I place that value into the
> StringBuilder Object.
> Thanks
Try Environment.NewLine
Remy
I am loosing the page break when I use the StringBuilder ToString() method
when I am formatting an email message. I will try the Environment.NewLine()
method and see if that retains the line break.
Does the StringBuilder cause the newline disappear, or is it something with
the mail component. What happens if you just set the
StringBuilder.ToString() to a variable and looked at it, is the newline
gone?
"Jim Heavey" <JimHeavey@.discussions.microsoft.com> wrote in message
news:9876DF24-F310-4FDC-826D-D7872576655C@.microsoft.com...
>I am loosing the page break when I use the StringBuilder ToString() method
> when I am formatting an email message. I will try the
> Environment.NewLine()
> method and see if that retains the line break.
>
I assume you are using c?
If you pass "\n" you'll get newline > chr(10)
If you want "\n" you might consider to use "\\n"
(Outlook express mangels this for me, use slash twice)
"Jim Heavey" <JimHeavey@.discussions.microsoft.com> schreef in bericht
news:1BC14F11-5DBA-4865-9CFB-2881598EB955@.microsoft.com...
> Hello, I a m building an email message in a StringBuilder Object and then
> using the StringBuilder ToString() method to get it to regular text. It
> appears to me that when I place a "\n" into the Stringbuilder object that
> when this is translated into text, I loose the page break. Is this true
> and
> I doing something wrong?
> I'm guessing that I could insert a special character into the
> StringBuilder
> object and then use the string Replace() method to translate that special
> character into a "\n" and perhaps this would work.
> Just wondering why it does not work when I place that value into the
> StringBuilder Object.
> Thanks

StringBuilder to Text

Hello, I a m building an email message in a StringBuilder Object and then
using the StringBuilder ToString() method to get it to regular text. It
appears to me that when I place a "\n" into the Stringbuilder object that
when this is translated into text, I loose the page break. Is this true and
I doing something wrong?

I'm guessing that I could insert a special character into the StringBuilder
object and then use the string Replace() method to translate that special
character into a "\n" and perhaps this would work.

Just wondering why it does not work when I place that value into the
StringBuilder Object.

ThanksHow are you noticing that you loose the break? In what context is this
happening?

"Jim Heavey" <JimHeavey@.discussions.microsoft.com> wrote in message
news:1BC14F11-5DBA-4865-9CFB-2881598EB955@.microsoft.com...
> Hello, I a m building an email message in a StringBuilder Object and then
> using the StringBuilder ToString() method to get it to regular text. It
> appears to me that when I place a "\n" into the Stringbuilder object that
> when this is translated into text, I loose the page break. Is this true
> and
> I doing something wrong?
> I'm guessing that I could insert a special character into the
> StringBuilder
> object and then use the string Replace() method to translate that special
> character into a "\n" and perhaps this would work.
> Just wondering why it does not work when I place that value into the
> StringBuilder Object.
> Thanks
Have you considered using Environment.Newline instead of "\n"?

Example:

StringBuilder textBuilder = new StringBuilder(512);
textBuilder.Append("Dear John,");
textBuilder.Append(Environment.Newline)

Perhaps that will help.

carl

"Jim Heavey" <JimHeavey@.discussions.microsoft.com> wrote in message
news:1BC14F11-5DBA-4865-9CFB-2881598EB955@.microsoft.com...
> Hello, I a m building an email message in a StringBuilder Object and then
> using the StringBuilder ToString() method to get it to regular text. It
> appears to me that when I place a "\n" into the Stringbuilder object that
> when this is translated into text, I loose the page break. Is this true
> and
> I doing something wrong?
> I'm guessing that I could insert a special character into the
> StringBuilder
> object and then use the string Replace() method to translate that special
> character into a "\n" and perhaps this would work.
> Just wondering why it does not work when I place that value into the
> StringBuilder Object.
> Thanks
Try Environment.NewLine

Remy
I am loosing the page break when I use the StringBuilder ToString() method
when I am formatting an email message. I will try the Environment.NewLine()
method and see if that retains the line break.
Does the StringBuilder cause the newline disappear, or is it something with
the mail component. What happens if you just set the
StringBuilder.ToString() to a variable and looked at it, is the newline
gone?

"Jim Heavey" <JimHeavey@.discussions.microsoft.com> wrote in message
news:9876DF24-F310-4FDC-826D-D7872576655C@.microsoft.com...
>I am loosing the page break when I use the StringBuilder ToString() method
> when I am formatting an email message. I will try the
> Environment.NewLine()
> method and see if that retains the line break.
I assume you are using c?

If you pass "\n" you'll get newline > chr(10)
If you want "\n" you might consider to use "\\n"
(Outlook express mangels this for me, use slash twice)

"Jim Heavey" <JimHeavey@.discussions.microsoft.com> schreef in bericht
news:1BC14F11-5DBA-4865-9CFB-2881598EB955@.microsoft.com...
> Hello, I a m building an email message in a StringBuilder Object and then
> using the StringBuilder ToString() method to get it to regular text. It
> appears to me that when I place a "\n" into the Stringbuilder object that
> when this is translated into text, I loose the page break. Is this true
> and
> I doing something wrong?
> I'm guessing that I could insert a special character into the
> StringBuilder
> object and then use the string Replace() method to translate that special
> character into a "\n" and perhaps this would work.
> Just wondering why it does not work when I place that value into the
> StringBuilder Object.
> Thanks

Tuesday, March 13, 2012

stuck on empty page after sending email with.........mailto:"email address here"

Hi, i have code that opens an Ms outlook new email message window on myGridviews' ItemUpdated event. I did this because of the easy with which users will find email addresses to send messages to with out the pain of remembering or cramming the so many company employee email accounts. After sending the email, outlook closes which is okay to me but the problem is, i now remain with a blank page instead of returning to the page with my Gridview from where i fired the update event that opened outlook. I wish i had away of posting or redirecting to another page or even better returning to the same page from ItemUpdated event that opened outlook was fired from. Iam not sure if this explaination is clear to any one reading it but below is the code iam talking about.

ProtectedSub GridView1_RowUpdated(ByVal senderAsObject,ByVal eAs System.Web.UI.WebControls.GridViewUpdatedEventArgs

Response.Redirect(mailto:my-email-account@dotnet.itags.org.ppp.co.ug

Response.redirect("Default.aspx") 'Why is this line of code not redirecting to Default.aspx

END SUb

Option Two: How can i open outlook when an event fires without using Response.Redirect because that is exactly what what is bringing me all this mess.

Dont use a Response.Redirect(), just use an HREF...


Your first response.redirect changes the page you are on, so the second one never fires.

Why not just show the email address when your user updates the row? Or use a pop-up to display the email address for the user to click.

Try creating a hidden iframe and setting the location of the iframe to the mailto address. This might do the trick, but I haven't tested it.

--JJ


This is my scenerio. when a row is updated, basically we are talking about a name field which is initially null being filled with an employee name. So when the user clicks update after typing the employee name in this field, On the itemUpdate event of this particular Gridview, outlook opens and then the administrator doing the update should lookup the email address in outlook of the same employee whose name was entererd prevously. The aim is to send a notification email that he has been assigned a record he/she should take charge of.

So at the end of the operation, a record should have been updated and an outlook email(not automatic) should have been send to the employee whose name was entered in the Gridviews' name field.


How do you use HREF in an event handle sub procedure.


By HREF, Curt means a HyperLink. You need to use a hyperlink and open a popup to send the mail

<a href="http://links.10026.com/?link=my-email-account@.ppp.co.ug" target="_blank">Send Mail</a>

Thanks