473,385 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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.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=<userna me>;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.

Apr 27 '06 #1
4 1009
What exact line is the error happening?

Jeff
"^MisterJingo^" <mi*********@gmail.com> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.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=<userna me>;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.

Apr 27 '06 #2
Jeff Dillon wrote:
What exact line is the error happening?

Hi Jeff,

It's happening on this line:

myConnection.Open()

Apr 27 '06 #3
Not sure about your connection string. Usually it's (local) and not
localhost.

http://www.connectionstrings.com

"^MisterJingo^" <mi*********@gmail.com> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com...
Jeff Dillon wrote:
What exact line is the error happening?

Hi Jeff,

It's happening on this line:

myConnection.Open()

Apr 27 '06 #4
Hi Jeff,

When i try that I get the following exception thrown:

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

Apr 28 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: WindAndWaves | last post by:
Hi Gurus The page below has a strange error. It seems to be working very well, just when you enter 8 or 9 for day, month or year then you get an error. I really have no idea where that is...
3
by: Alfonso Morra | last post by:
I have some code that I am porting over from C. It is full of static functions and global variables. I have got around this by wrapping most of the code in a singleton object. However, I am...
3
by: Don McNamara | last post by:
Hi, I've hit quite a strange problem with XmlSerializer on my W2K3 server. When I serialize/deserialize using an exe on my local computer (XP), everything works fine. When I put the code out on...
2
by: Rhino | last post by:
I am trying to write a trigger/UDF combination that closely follows the example given in the following DeveloperWorks article:...
25
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's...
1
by: Nadav | last post by:
I have a strange problem with inherited controls: I have created two user controls called UserLoginA & UserLoginB. One of the properties of these controls is of type UserGroup ( a class I...
17
by: jensen bredal | last post by:
Hello, i'm struggling with a somehow badly understood session scenario. I provide acces to my pages based on form authentication using Session cookies. Som of my pages are supposed to be...
4
by: Praveen_db2 | last post by:
Hi All I am getting strange errors in my db2diag.log can any one tell me what these errors mean?? Following is the code from my db2diag.log...
6
by: Hannibal111111 | last post by:
I am getting a strange situation with a .NET 1.1 web application that we have deployed. I have made an update to a code behind page in 1 file, and then made an update to another code behind page. ...
9
by: Larry | last post by:
I was testing the buffer size of system call, read(), and found a strange error on Ubuntu 7.10 server. The code is attached. If the BUFFSIZE is set to from 128 to 255, the code will produce an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.