.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

Format String

Posted By:      Posted Date: September 28, 2010    Points: 0   Category :Sql Server

My Data String is 2010-02-10

How to Change format data string  day-month-year

Ex. 10-02-2010 but Data is String

Thank You.

View Complete Post

More Related Resource Links

Input string was not in a correct format.


Hi, I just started learning asp.net

i set simple application but i get this error that  "Input string was not in a correct format"

Input string was not in a correct format.

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: Input string was not in a correct format.

Source Error:

Line 10:     protected void Page_Load(object sender, EventArgs e)
Line 11:     {
Line 12:         decimal num1 = Decimal.Parse(txtNumber1.Text);
Line 13:         decimal num2 = Decimal.Parse(txtNumber2.Text);
Line 14:         decimal ans = num1 + num2;

How can I correct this error




Cannot FindByThumbprint - Invalid Hexadecimal string format

I'm trying to set up a sample WCF service using a self-signed certificate.  For some reason, I repeatedly get the error "FormatException - Invalid hexadecimal string format." I was initially trying it in the config file but decided to try setting it up in code but still get the same error. I then tried it on a different machine and it works just fine.  I would appreciate any suggestions.  Here are the details. Environment:  Windows 7 Home Premium, Visual Studio 2010 C# Express Edition, .NET 4.0 Code:     // Create the host ServiceHost host = new ServiceHost(hostType);     string valueToFind = "‎‎‎‎‎66 31 bf 9e f7 4f 9e b6 c9 d5 a6 0c ba 6a be d1 f7 bd ef 7b"; host.Credentials.ServiceCertificate.SetCertificate(   StoreLocation.CurrentUser, StoreName.Root, X509FindType.FindByThumbprint, valueToFind);     The exact same code runs just fine on another machine.  No complaints of an invalid hexadecimal value.  Here are the details of the other machine: Environment:  Windows XP, Visual Studio 2010 C# Premium, .NET 4.0 Any ideas?

SlideShowExtender - Sys.Net.WebServiceProxy._createFailedError(methodName, String.format(Sys.Res.web

Hello,   I put a SliderShowExtender and i created a web service with a function that return AjaxControlToolkit.Slide(), but when a run the project give me the error: Microsoft JScript runtime error: Sys.Net.WebServiceFailedException: The server method 'returnLogo' failed with the following error: <html>    <head>        <title>Unknown web method 'returnLogo'.<br>Parameter name: methodName</title>        <style> ...   Anybody know why?   Tks

Input string was not in a correct format.

I am trying to convert a null value to a double value using convert function in C#. Can anybody help me in this regards... I am getting a null value in a variable named "gridCol1" Step 1 - I am doing                Convert.ToDouble ( gridCol1.ToString() );                Error : "Input string was not in a correct format."

My problem with an gridView, Input string was not in a correct format.

Hello all ! I'am actually encounter problem with an gridView which is composed of five columns, the both first are string type, third is date and the two last are linkbutton to edit or delete rows. On clicking edit button, i catch good event to edit and traitment  work fine but on living function an error occur with this message : error : System.FormatException: Input string was not in a correct format. stackTrace :   [FormatException: Input string was not in a correct format.] System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +7471479 System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119 System.Web.UI.WebControls.GridView.GetRowIndex(GridViewRow row, String commandArgument) +99 System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +602 System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +207 System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175 System.Web.UI.Page.ProcessRequestMain(Boolean inclu

Usual solutions not the problem for Format of the initialization string does not conform to specific

I know that there are normally two causes/solutions for the "Format of the initialization string does not conform to specification starting at index 0" error message.  The two normal suggestions are a problem with the connection string or it is surrounded by quotes in Dimming the connection. I get the message while running in debug (though it is pulling the selected row ID value correctly).However neither of those are the case in my file.  I know the connection string is configured correctly because it works in the rest of the page.  Further I don't have quotes in the Dim connection part.  Relevant bits of code below.Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.ImageButton Imports System.Web.UI.WebControls.DataControlField Imports System.Data Imports System.Data.SqlClient Imports System.Configuration Imports System.Object Imports System.DirectoryServices Partial Class Default2 Inherits System.Web.UI.Page 'Private auth As authenticate 'Private dt As DataTable 'Private programs As DataRow() Private dbConnection As String = "KMConnectionString" . . . Sub btnPlay(ByVal sender As Object, ByVal e As EventArgs) 'grab video ID Dim videoID = GridView1.SelectedValue.ToString() Response.Write(videoID) Dim con As New SqlConnection(dbConnection)

Need to convert query string(date - 09/15/2010) to a text format - yyyymmdd

I am fairly new to C # and need some assistance with a form page.  I have created a simple form that requires the user to select a beginning date and ending date.  I then pass the values to my code behind page via query strings.  I have them passing, but I need the format to be change to a different format.  Unfortunately the database does not use the standard date format.  It requires the date to be in a text format as YYYYMMDD.Form: <tr> <td> Beginning Date:</td> <td><asp:TextBox runat="server" ID="begDate"></asp:TextBox> <asp:Image ID="Image2" ImageUrl="~/images/calendar_schedulehs.png" runat="server" /></td> </tr> Code Behind: protected void createReport_Click(object sender, EventArgs e) { StringBuilder url = new StringBuilder("Report/TopCustomer.aspx?"); url.Append("BegDate=" + begDate.Text); url.Append("&EndDate=" + endDate.Text); url.Append("&Brnch=" + ddlLocation.SelectedValue); Response.Redirect(url.ToString()); Current URL: TopCustomer.aspx?BegDate=09/15/2010&EndDate=09/30/2010&Brnch=300I need to have the above URL change to:TopCustomer.aspx?BegDate=20100915&E

MSG durring Installatioin:Input String was not in a correct format

I am in the process in installing SQL  Express 2008-R2. While running Setup, the following box pops up: SQL Server Steup faulure. SQL Server Setup has ecountered the following error: Input string was not in a correct format... Any ideas on how to correct this? Thanks in advance.  


Hi all,Here's some simple code<a href='<%= string.Format("../Print/Print1.aspx?withParameter={0}", Para )%>'>HyperLinkText</a>and it works well. so i guess i can write anything like this, so i wrote a test:<input type="button" value="Btn1" onclick='<%= string.Format("window.open('','_blank')") %>'/> <input type="button" value="Btn2" onclick="window.open('','_blank')"/>However, Btn1 does not work.. for some reason i have to NOT to use server control, so i wite it in inline-code style,why the first hyperlink work well, but Btn1 fails?could anyone tell me?thank you~

Input string was not in a correct format.


DropDownList ddlCardDetails = LoginView2.FindControl("ddlCardDetails") as DropDownList;

        BurnbetDataContext ctx = new BurnbetDataContext("data source=.\\SQLEXPRESS;Integrated Security=SSPI;" +
                           "AttachDBFilename=|DataDirectory|\\BurnbetDatabase.mdf;User Instance=true");

            int Id = Convert.ToInt32(ddlCardDetails.SelectedValue.Split('|')[0]);
            tbl_Payment democustomer = ctx.tbl_Payments.SingleOrDefault(c => c.ID == Id);

        if (democustomer != null)




Input string was not in a correct format


I am trying to update a coulmn in datatable but keep getting error:

Input string was not in a correct format.Couldn't store <&nbsp;> in SortOrder Column.  Expected type is Int32.

SortOrder is column of Type Integer that either contain Null or number.

Any ideas? below is my code

   If e.CommandName = "Reset" Then
            Dim index As Integer = Integer.Parse(e.CommandArgument)
            dt = CType(Cache("dt"), DataTable)
            Dim value As Integer = 0
            value = Convert.ToInt32(dt.Rows(index)("ContentID").ToString())

            Dim SortOrderNum As Integer = 0
            SortOrderNum = dt.Rows(index)("SortOrder").ToString()
            dt.Rows(index)("SortOrder") = DBNull.Value   'dt.Rows(index - 1)("SortOrder")

            dtNew = dt.Copy()
            dgArticles.DataSource = dt
            Dim i As Integer = 0
            For i = 0 To dgArticles.Rows.Count - 1
                dtNew.Rows(i)("ContentID") = dgArticles.Rows(i).Cells(0).Text

                dtNew.Rows(i)("Headline") = dgArticles.Rows(i).Cells(1).Text

                dtNew.Rows(i)("SiteName") = dgArticles.Rows(i).Cells(2

datetime formating with string.format


I have a table in my SQL DB that is a DateTime table, what I want to do is take the numeric datetime it stores and convert it to a long date (i.e. 12/12/2012 conversts to December 12, 2012). Seaching the forums it looks like the string.format is the way to go and searching for info on that I found http://www.csharp-examples.net/string-format-datetime/ which lists all the different formats but they do not list a formating string to convert to the format I want to use. Does anyone know what format string I would use to convert a numeric date to a long date like I want? And can you show it in a code example because I am not 100% sure I understand the code examples shown on that site.

dateTime string format


when my system date separator set to "-", the following return the date format with "dd-mm-yyyy HH:mm"

DateTime b = DateTime.ParseExact(date, "dd/MM/yyyy HH:mm", provider);
                            strDate = b.ToString("dd/MM/yyyy HH:mm");

return strDate;


why? how can i return the dayeformat with "/" separator ingore PC datatime setting

Help me with this error Format of the initialization string does not conform to specification starti


I am getting this error-- Format of the initialization string does not conform to specification starting at index 0. whenever i want to insert some record into DB using store procedures.

 String cstr = ConfigurationManager.ConnectionStrings["cstr"].ConnectionString;
       SqlConnection con = new SqlConnection("cstr"); 
        cmd = new SqlCommand("insert1", con);
        cmd.CommandType = CommandType.StoredProcedure;  
         cmd.Parameters.Add(new SqlParameter("@empid", SqlDbType.VarChar)).Value = TextBox1.Text;  
         cmd.Parameters.Add(new SqlParameter("@name", SqlDbType.VarChar)).Value = TextBox2.Text;  

and my connection string in web.config

		<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
			<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35

comparing a date in string format to date


I have a program that is using credit card info and the expiration date is selected by the user clicking a dropdownlist for the month and a dropdownlist for the year.  I want to show a label message if the user tries to proceed while the month and year are evaluated as being earlier that the current month/year.  Can someone help me determine how to evaluate this? 

populating textboxes via data reader - how do I format the string??


Here is what I have tried:

txtCost.Text = string.Format("{o:c}", dr["Cost"]);

Here is the error I receive.  How can I format the data that is coming from the data reader into currency format???  Also, is there a way to format it into currency without the dollar sign?

Input string was not in a correct format.

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: Input string was not in a correct format.

string not converting in datetime format


hi to all,

 i'm developing a website. i have a registration form where user can registered with this website.

this have a birthdate field for store user's birthdate.that is a textbox.

here is my code.

protected void submitbtn_Click(object sender, ImageClickEventArgs e)
System.Globalization.CultureInfo en = new System.Globalization.CultureInfo("en-GB");
li.fname = firstname.Text;
li.lname = lastname.Text;
li.gender = gender.SelectedItem.Text;
li.date = Convert.ToDateTime(birthdate.Text,en); //getting error here
li.address = addrs.Text;
li.contactno = contno.Text;
li.countryid =Convert.ToInt32( dropcontry.SelectedValue);
li.stateid = Convert.ToInt32( dropstate.SelectedValue);
li.cityid =Convert.ToInt32( dropcity.SelectedValue);
li.emailid = prmrmailid.Text;
li.username = createuserid.Text;
li.password = createpassword.Text;
li.secutityque = dropsecque.SelectedItem.Text;
li.securityans = secanswer.Text;

int a = li.personid;
li.personid= a;
int p = li.personid;
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend