Results 1 to 1 of 1

Thread: Input string was not in a correct format.

  1. #1

    Thread Starter
    Lively Member freightliner's Avatar
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    123

    Exclamation Input string was not in a correct format.

    Hi,

    I am trying to make a C/ODBC connection with a Navision Database through ASP.NET. This works good, but when i try to get other values other than CODE or TEXT, i get the error shown in the subject.

    VB Code:
    1. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.        Dim dsn As String
    3.         Dim sql As String
    4.         Dim cn As OdbcConnection
    5.         Dim cmd As OdbcCommand
    6.         Dim dr As OdbcDataReader
    7.  
    8.         dsn = "DRIVER={C/ODBC 32 bit};"
    9.         dsn = dsn & "DSN=DSNNAME;"
    10.         dsn = dsn & "UID=user;"
    11.         dsn = dsn & "PWD=pwd;"
    12.         dsn = dsn & "sName=SRVRNAME;"
    13.         dsn = dsn & "NType=tcp;"
    14.         dsn = dsn & "CN=My Company;"
    15.         dsn = dsn & "CSF=Yes;"
    16.         dsn = dsn & "SERVER=N"
    17.  
    18.  
    19.         cn = New OdbcConnection(dsn)
    20.         cn.Open()
    21.  
    22.         sql = "SELECT No_, Name, Address, City, ""Phone No_"", Amount FROM "
    23.         Select Case Request.QueryString("Table")
    24.             Case 90000
    25.                 sql = sql & "Cust50"
    26.             Case 90001
    27.                 sql = sql & "Cust500"
    28.             Case 90002
    29.                 sql = sql & "Cust500"
    30.             Case 90003
    31.                 sql = sql & "CustFull"
    32.         End Select
    33.  
    34.         cmd = New OdbcCommand(sql, cn)
    35.  
    36.         dr = cmd.ExecuteReader(CommandBehavior.SingleResult)
    37.  
    38.         dtgCustomers.DataSource = dr
    39.         dtgCustomers.DataBind()
    40.         lblElapsed.Text = "Time needed to load: " & Environment.TickCount - Request.QueryString("ms") & " Milliseconds"
    41.  
    42.         cn.Close()
    43. End sub

    Does anyone know how i can solve this or at least make it be shown or parsed to string(the values do not have to be edited).
    It is the Amount field that has the type Decimal.

    Hope anyone can help me.

    Greets,
    Freightliner

    [EDIT:] Forgot to say i get the error when i connect it to the datagrid:
    Server Error in '/WebApplication1' 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:


    Line 63:
    Line 64: dtgCustomers.DataSource = dr
    Line 65: dtgCustomers.DataBind()
    Line 66: lblElapsed.Text = "Time needed to load: " & Environment.TickCount - Request.QueryString("ms") & " Milliseconds"
    Line 67:


    Source File: c:\inetpub\wwwroot\WebApplication1\CODBC.aspx.vb Line: 65

    Stack Trace:


    [FormatException: Input string was not in a correct format.]
    System.Number.ParseDecimal(String s, NumberStyles style, NumberFormatInfo info) +0
    System.Decimal.Parse(String s, IFormatProvider provider) +28
    System.Data.Odbc.OdbcDataReader.internalGetDecimal(Int32 i)
    System.Data.Odbc.OdbcDataReader.GetValue(Int32 i, TypeMap typemap)
    System.Data.Odbc.OdbcDataReader.GetValue(Int32 i)
    System.Data.Odbc.OdbcDataReader.GetValues(Object[] values)
    System.Data.Common.DbEnumerator.MoveNext()
    System.Web.UI.WebControls.DataGrid.CreateAutoGeneratedColumns(PagedDataSource dataSource)
    System.Web.UI.WebControls.DataGrid.CreateColumnSet(PagedDataSource dataSource, Boolean useDataSource)
    System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean useDataSource)
    System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e)
    System.Web.UI.WebControls.BaseDataList.DataBind()
    WebApplication1.CODBC.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebApplication1\CODBC.aspx.vb:65
    System.Web.UI.Control.OnLoad(EventArgs e)
    System.Web.UI.Control.LoadRecursive()
    System.Web.UI.Page.ProcessRequestMain()




    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
    Last edited by freightliner; Sep 30th, 2004 at 08:41 AM.
    very handy: [vbcode][/vbcode]
    VB.NET - VB6 - VBA - ASP - RPG(AS/400) - C++ - java - SQL

    look in the help, many probs can be solved that way.
    I know, i'm to lazy too.

    PLEASE PUT RESOLVED IF RESOLVED!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width