Well, I've made (somewhat) the move to .NET (2003) and am slowly starting to work with it (during my free time). Anyway, I've run into something that I haven't been able to find too much information on. I've found several threads addressing the error but nothing really clear (at least to me) in terms of how to address it. I've seen suggestions ranging from making sure I'm importing the proper stuff to re-installing visual studio and the .NET framework (please don't let that be the answer

).
The program I'm working on does use a database (msde) but that isn't what's causing the error so I'm hoping it's OK that I posted here instead of in the Database Forum (if it's not, I'll more than understand if you have to move this thread over to there).
Anyway, here's the code that's causing the problem.
Code:
' use Try/Catch to make sure executenonquery works properly
Try
sqlCmd.ExecuteNonQuery()
Catch sqlInsertE As Exception
MessageBox.Show(sqlInsertE, "SQL Insert Error")
End Try
First off, I'm doing an SQLClient.SQLCommand to run an Insert into the database. And that is working fine. For "testing" purposes, I made it cause an error so I could see how the Try/Catch would work. But now, when I run the code, I get:
Quote:
An unhandled exception of type 'System.InvalidCastException' occured ...
Additional Information: specified cast is not valid
|
Am I leaving something out? Or is there a problem with the Try/Catch? Any and all help is greatly appreciated.
Thanks in advance.