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


Top 5 Contributors of the Month
Kaviya Balasubramanian
Imran Ghani
Post New Web Links

{"Input string was not in a correct format."}

Posted By:      Posted Date: October 07, 2010    Points: 0   Category :WCF
 

  Trying to write a web Service.

Common.cs

namespace HL7InterfaceWebServiceLibrary
{
  public class Common : ICommon
  {
    private ClientPatientID CPI = null;

 public ClientPatientID GetClientPatientID(string caseNum)
    {
      CPI = new ClientPatientID();
      string caseNo = caseNum.Trim();
      using (var cnn = new SqlConnection(Properties.Settings.Default.ConnectionString))
      {
        try
        {
          using (var cmd = new SqlCommand("[HL7].[GetClientPatientID]", cnn))
          {
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@CaseNo", caseNo));
            cnn.Open();
            using (SqlDataReader myreader = cmd.ExecuteReader())
            {
              while (myreader.Read())
              {
                CPI.CPatientID = Convert.ToInt32(myreader["ClientPatientID"].ToString());
              }
            }
          }
        }
        catch (Exception ex)
        {
          throw;
        }
        finally
        {
          cnn.Close();
          cnn.Dispose();
        }
      }
      return CPI;
    }


}

ICommon.cs

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace HL7InterfaceWebSer


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

 

thanks

 


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

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.  

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)
        {


            ctx.tbl_Payments.DeleteOnSubmit(democustomer);
            ctx.SubmitChanges();
        }

        GetCardDetails();

    }

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")

            dt.AcceptChanges()
            dtNew = dt.Copy()
            dgArticles.DataSource = dt
            dgArticles.DataBind()
            dt.AcceptChanges()
            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

Serious problem on UpdatePanel and GridView (Input string was not in a correct format)

  

I have implemented a custom gridview paging method using the pagertemplate tag. The source code is the following:

 

 

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
      		<ContentTemplate>
      		<fieldset class="ads">
			<legend>?????????</legend>
			<br />            
            <asp:GridView ID="gvResults" runat="server" AutoGenerateColumns="False" DataKeyNames="CHId" CssClass="grid" GridLines="None" AllowPaging="true" AllowSorting="true&q

Enterprise Library 4.0 error: Input string was not in a correct format.

  

I am trying to insert candidates information into SQL Server database. I have written the corresponding stored procedure like below in SQL server:

ALTER PROCEDURE [dbo].[USPInsertCandidate]
	@candidate_name varchar(60),
	@dob datetime,
	@gender char,
	@current_location varchar(60),
	@mobile_no_one varchar(20),
	@mobile_no_two varchar(20),
	@home_phone	varchar(20),
	@work_phone varchar(20),
	@email_id varchar(100),
	@passport varchar(20),
	@as_on_date datetime,
	@file_upload_path varchar(255),
	@availability char,
	@applied_position varchar(30),
	@max_round_id int,
	@certification_comment varchar(2000),
	@source_id int,
	@source_comment varchar(2000),
	@skillset_comment varchar(2000),
	@max_status_id int,
	@total_exp_year int,
	@total_exp_month int,
	@source_date datetime,
	@user_id int,
	@visa varchar(20),
	@qualification varchar(100)
AS
BEGIN
	declare @candidate_id int;
	set @candidate_id = dbo.GetCandidateID();
	insert into candidates(candidate_id, candidate_name, dob, gender, current_location, mobile_no_one, mobile_no_two, home_phone, work_phone, email_id, 
							passport, as_on_date, file_upload_path, availability, applied_position, max_round_id, certification_comment,
							source_id, source_comment, skillset_comment, max_status_id, total_exp_year, total_exp_month, source_date,
							user_id, visa, qualification)
	values

Input string was not in a correct format.

  
what is this error.what wrong in this code

Class1 obj1 = new Class1();
            Console.WriteLine("Enter Any Two Numbers");
            obj1.PNum1 = Convert.ToInt32(Console.ReadLine());
            obj1.PNum2 = Convert.ToInt32(Console.ReadLine());
            obj1.add();
            Console.WriteLine("Sum is:" + obj1.PResult);
            obj1.Multiply();
            Console.WriteLine("Muliply is:" + obj1.PResult);
            obj1.Divide();
            Console.WriteLine("Product is:" + obj1.PResult);
            obj1.Subtract();
            Console.WriteLine("Substract is:" + obj1.PResult);



Input string was not in a correct format

  
I'm having some intermittent trouble with an editform that I have heavily customized.  I think I have it narrowed down to the offending part but I'm stuck on how to fix it.

My page is an editform with tabs created from here: http://www.sharepointchamps.com/?p=21#more-21
And a cascading dropdown menu (which I think is the problem) created from here: http://mdasblog.wordpress.com/2009/07/14/cascading-columns-in-a-sharepoint-form/

Intermittently, when I access the form and either hit OK or Edit Page I get the following error:

Server Error in '/' Application.
--------------------------------------------------------------------------------

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: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[FormatException: Input string was not in a correct format.]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer

Strange "Input string was not in a correct format" after upgrading to .net 4.0 (VS 2010)

  

Hi guys, I am at a loss here.  I have a gridview that was displaying and handling postbacks correctly, that is, until I upgraded to .net 4.0 (vs 2010) from .net 3.5. Now I am getting the classic (and in this context meaningless) "Input string was not in a correct format" error upon postback. The postback is initiated by a command button and the row command event handles everything nicely.

The trace shows internal grid postback handling and nothing else:

[FormatException: Input string was not in a correct format.]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +9594283
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119
   System.Convert.ToInt32(String value, IFormatProvider provider) +48
   System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +1047
   System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +210
   System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
 

C#: SELECT @@IDENTITY AS 'Identity'. Error:Input string was not in a correct format.

  

 

Hi

 

Using VS2005, SQL Server 2005, FormView,C#.

Please Note: I can not use stored proecdeures.

 

I currently Insert a record in my FormView.

 

I need to then retrieve the IssueID of the inserted record and use the latest IssueID to insert a record into another table.

Input string was not in a correct format.

  

        if (e.CommandName == "UrediPotniNalog")
        {

            int ID = Convert.ToInt32(PregledNalogovGrid.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[0].ToString());

       //     Session["ID"] = ID;
        }

<asp:GridView ID="PregledNalogovGrid" runat="server" AutoGenerateColumns="False" DataKeyNames="ID,UserId,IdSifra"
            OnRowUpdated="PregledNalogovGrid_RowUpdated" AllowSorting="True"  onrowcommand="ViewPregledNalogov_RowCommand"
            EnableModelValidation="True" 
            onselectedindexchanged="ProductsGrid_SelectedIndexChanged">

            <Columns>

<asp:TemplateField HeaderText="Stevilka">
    <ItemTemplate>
        <asp:LinkButton ID="LinkButton1" onclick="PotniNalogUredi_Click" CommandName="UrediPotniNalog" runat="server"><%# Eval("Stevilka")%>/<%# Eval("Leto") %></asp:LinkButton>
    </ItemTemplate>
    <ItemStyle Width="330px" />
</asp:TemplateField>

I've used only linkbutton and I do not know if what influence it.


Error: Input string was not in a correct format. using c# .net

  

anyone can help me regarding this error:

Exception Details: System.FormatException: Input string was not in a correct format.

here's my code behind:

referenceno = Convert.ToInt32(drReaderpay["STAFF_ID"]);

note: staff_id = 123456-8


Input string was not in a correct format

  

Hello. Any help will be appreciated.

This is the error:

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 38: 
Line 39: 'if the particular column data more than highEnd, then take the value + 1 and store to highEnd
Line 40: If Convert.ToDecimal(myColumn(catId)) > highEnd Then
Line 41: highEnd = Convert.ToDecimal(myColumn(catId)) + 1
Line 42: End If

Source File: G:\Year 3 fyp\WebSite1\view linegraph.aspx.vb    Line: 40

Stack Trace:

Input string was not in a correct format.

  

 

Private Sub Page_Load(source As Object, e As EventArgs)
	Dim email As String = Request.QueryString("email")
	Dim vc As Integer = -1

	If Request.QueryString("vc") IsNot Nothing Then
            vc = Convert.ToInt32(Request.QueryString("vc"))
	End If

	Dim newsletterName As String = ConfigurationManager.AppSettings("Newsletter_Name")

	Dim validationCode As Integer
	Dim returnValue As Integer

	Dim cmdstr As String

	If email IsNot Nothing AndAlso vc = -1 Then
		' Send email for validation

		returnValue = DatabaseHelper.IsSubscriberEmailValidated(email, validationCode)

		Select Case returnValue
			Case 1
				' User is subscribed but email address has not been validated

				Try
					Util.SendValidationEmail(email, validationCode)

					Result.Text = "An email has been sent at " + email + ". Please click the link " + "in that email to validate your email address and complete the registration " + "process. <a href="""">Click here</a> to go to the home page of our web site."
				Catch generatedExceptionName As Exception
					Result.Style.Add("color", "red")
					Result.Text = "The validation email to confirm your email address could not be " + "sent at this time. <a href=""ValidateEmail.aspx?email=" + Server.UrlEncode(email) + """>Click here</a> to try again."
				End Try

				Exit Sele
Categories: 
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