ADO.NET Specified cast is not valid

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2004
Posts: 6
Reputation: ralaing is an unknown quantity at this point 
Solved Threads: 0
ralaing ralaing is offline Offline
Newbie Poster

ADO.NET Specified cast is not valid

 
0
  #1
Aug 6th, 2004
Specified cast is not valid.
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.

Source Error:


Line 12: Public Sub AddCart(ByVal CustomerID As Integer, ByVal ProductID As Integer, ByVal Qty As Integer)
Line 13: 'Add a single row item to the cart
Line 14: Dim objCmd As New OleDbCommand("uspAddCart", objConn)
Line 15: objCmd.CommandType = CommandType.StoredProcedure
Line 16:

Problem is line 14, but why? Everything was working - now it isn't! What might I have done?

Connection info:
Dim configurationAppSettings As System.Configuration.AppSettingsReader = New System.Configuration.AppSettingsReader

Private objConn = CType(configurationAppSettings.GetValue("DSN", GetType(System.String)), String)

...and in Web.config:
<add key="DSN" value="Provider=Microsoft.Jet.OleDB.4.0;Data Source=c:\files\access\data\ProvidenceData.mdb" />
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 898
Reputation: Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light 
Solved Threads: 28
Moderator
Tekmaven's Avatar
Tekmaven Tekmaven is offline Offline
The C# Man, Myth, Legend

Re: ADO.NET Specified cast is not valid

 
0
  #2
Aug 6th, 2004
Originally Posted by ralaing
Private objConn = CType(configurationAppSettings.GetValue("DSN", GetType(System.String)), String)
objConn as no variable type...?
-Ryan Hoffman

.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 6
Reputation: ralaing is an unknown quantity at this point 
Solved Threads: 0
ralaing ralaing is offline Offline
Newbie Poster

Re: ADO.NET Specified cast is not valid

 
0
  #3
Aug 10th, 2004
Originally Posted by Tekmaven™
objConn as no variable type...?
Sorry, still trying to get a handle on this stuff. If the following works for an SQL connection, why doesn't similar code work for oleDB?

Private objConn As SqlConnection
Private objCmd As SqlCommand
Private dsn As String = ConfigurationSettings.AppSettings("dsn")

Public Function GetSingleTaskObs(ByVal intObservationID As Integer) As SqlDataReader
'Get Base observation details for a given ObservationID
Try
objConn = New SqlConnection(dsn)
objCmd = New SqlCommand("usp_GetObservation", objConn)
objCmd.CommandType = CommandType.StoredProcedure
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC