Home All Groups Group Topic Archive Search About

Strange error - help needed

Author
27 Apr 2006 2:32 PM
^MisterJingo^
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.InvalidCastException: Specified cast is not
valid.


Line 60:         Dim myCommand As New MySqlCommand(myInsertQuery)
Line 61:         myCommand.Connection = myConnection
Line 62:         myConnection.Open()
Line 63:         myCommand.ExecuteNonQuery()
Line 64:         myCommand.Connection.Close()


from this code:

Dim myConnectionString As String
="SERVER=localhost;DATABASE=evaluation;UID=<username>;PASSWORD=<password>;"

Dim myConnection As New MySqlConnection(myConnectionString)
Dim myInsertQuery As String = "insert into tbl_ssa (ipAddress) values
('127.188.01.01')"
Dim myCommand As New MySqlCommand(myInsertQuery)
myCommand.Connection = myConnection
myConnection.Open()
myCommand.ExecuteNonQuery()
myCommand.Connection.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.

Author
27 Apr 2006 4:49 PM
Jeff Dillon
What exact line is the error happening?

Jeff
Show quoteHide quote
"^MisterJingo^" <misterji***@gmail.com> wrote in message
news:1146148336.125340.210470@e56g2000cwe.googlegroups.com...
>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.InvalidCastException: Specified cast is not
> valid.
>
>
> Line 60: Dim myCommand As New MySqlCommand(myInsertQuery)
> Line 61: myCommand.Connection = myConnection
> Line 62: myConnection.Open()
> Line 63: myCommand.ExecuteNonQuery()
> Line 64: myCommand.Connection.Close()
>
>
> from this code:
>
> Dim myConnectionString As String
> ="SERVER=localhost;DATABASE=evaluation;UID=<username>;PASSWORD=<password>;"
>
> Dim myConnection As New MySqlConnection(myConnectionString)
> Dim myInsertQuery As String = "insert into tbl_ssa (ipAddress) values
> ('127.188.01.01')"
> Dim myCommand As New MySqlCommand(myInsertQuery)
> myCommand.Connection = myConnection
> myConnection.Open()
> myCommand.ExecuteNonQuery()
> myCommand.Connection.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.
>
Author
27 Apr 2006 6:23 PM
^MisterJingo^
Jeff Dillon wrote:
> What exact line is the error happening?
>
Hi Jeff,

It's happening on this line:

myConnection.Open()
Author
27 Apr 2006 7:03 PM
Jeff Dillon
Not sure about your connection string. Usually it's (local) and not
localhost.

http://www.connectionstrings.com

Show quoteHide quote
"^MisterJingo^" <misterji***@gmail.com> wrote in message
news:1146162228.026617.52300@i40g2000cwc.googlegroups.com...
> Jeff Dillon wrote:
>> What exact line is the error happening?
>>
> Hi Jeff,
>
> It's happening on this line:
>
> myConnection.Open()
>
Author
28 Apr 2006 8:44 AM
^MisterJingo^
Hi Jeff,

When i try that I get the following exception thrown:

Exception Details: System.Net.Sockets.SocketException: No such host is
known