Strange error - help needed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ^MisterJingo^

    #1

    Strange error - help needed

    I am getting the following error:

    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.InvalidC astException: Specified cast is not
    valid.


    Line 60: Dim myCommand As New MySqlCommand(my InsertQuery)
    Line 61: myCommand.Conne ction = myConnection
    Line 62: myConnection.Op en()
    Line 63: myCommand.Execu teNonQuery()
    Line 64: myCommand.Conne ction.Close()


    from this code:

    Dim myConnectionStr ing As String
    ="SERVER=localh ost;DATABASE=ev aluation;UID=<u sername>;PASSWO RD=<password>;"

    Dim myConnection As New MySqlConnection (myConnectionSt ring)
    Dim myInsertQuery As String = "insert into tbl_ssa (ipAddress) values
    ('127.188.01.01 ')"
    Dim myCommand As New MySqlCommand(my InsertQuery)
    myCommand.Conne ction = myConnection
    myConnection.Op en()
    myCommand.Execu teNonQuery()
    myCommand.Conne ction.Close()

    I have no idea why this is happening. The database and table exist, I
    can connect with other projects.

    Any help in sorting this out would be greatly appreciated.

  • Jeff Dillon

    #2
    Re: Strange error - help needed

    What exact line is the error happening?

    Jeff
    "^MisterJin go^" <misterjingo@gm ail.com> wrote in message
    news:1146148336 .125340.210470@ e56g2000cwe.goo glegroups.com.. .[color=blue]
    >I am getting the following error:
    >
    > 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.InvalidC astException: Specified cast is not
    > valid.
    >
    >
    > Line 60: Dim myCommand As New MySqlCommand(my InsertQuery)
    > Line 61: myCommand.Conne ction = myConnection
    > Line 62: myConnection.Op en()
    > Line 63: myCommand.Execu teNonQuery()
    > Line 64: myCommand.Conne ction.Close()
    >
    >
    > from this code:
    >
    > Dim myConnectionStr ing As String
    > ="SERVER=localh ost;DATABASE=ev aluation;UID=<u sername>;PASSWO RD=<password>;"
    >
    > Dim myConnection As New MySqlConnection (myConnectionSt ring)
    > Dim myInsertQuery As String = "insert into tbl_ssa (ipAddress) values
    > ('127.188.01.01 ')"
    > Dim myCommand As New MySqlCommand(my InsertQuery)
    > myCommand.Conne ction = myConnection
    > myConnection.Op en()
    > myCommand.Execu teNonQuery()
    > myCommand.Conne ction.Close()
    >
    > I have no idea why this is happening. The database and table exist, I
    > can connect with other projects.
    >
    > Any help in sorting this out would be greatly appreciated.
    >[/color]


    Comment

    • ^MisterJingo^

      #3
      Re: Strange error - help needed

      Jeff Dillon wrote:[color=blue]
      > What exact line is the error happening?
      >[/color]
      Hi Jeff,

      It's happening on this line:

      myConnection.Op en()

      Comment

      • Jeff Dillon

        #4
        Re: Strange error - help needed

        Not sure about your connection string. Usually it's (local) and not
        localhost.

        All connection strings in one place. Find the syntax for your database connection using ADO.NET, ADO, ODBC, OLEDB, C#, VB, VB.NET, ASP.NET and more.


        "^MisterJin go^" <misterjingo@gm ail.com> wrote in message
        news:1146162228 .026617.52300@i 40g2000cwc.goog legroups.com...[color=blue]
        > Jeff Dillon wrote:[color=green]
        >> What exact line is the error happening?
        >>[/color]
        > Hi Jeff,
        >
        > It's happening on this line:
        >
        > myConnection.Op en()
        >[/color]


        Comment

        • ^MisterJingo^

          #5
          Re: Strange error - help needed

          Hi Jeff,

          When i try that I get the following exception thrown:

          Exception Details: System.Net.Sock ets.SocketExcep tion: No such host is
          known

          Comment

          Working...