•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 456,488 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,734 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 55246 | Replies: 2
![]() |
| |
•
•
Join Date: Aug 2004
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
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" />
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" />
•
•
•
•
Originally Posted by ralaing
Private objConn = CType(configurationAppSettings.GetValue("DSN", GetType(System.String)), String)
objConn as no variable type...?
-Ryan Hoffman
ASP.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
ASP.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
•
•
Join Date: Aug 2004
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
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
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- link access table in ADO.NET (VB.NET)
- How good is ADO.NET vNext CTP now? (C#)
- Saving Excel Spreadsheet using ADO.net gives inconsistent results (C#)
- DataGrid with ado.net. (VB.NET)
- Long ado net question but urgent help required (ASP.NET)
- ADO.NET question modification. (VB.NET)
- ADO.Net SQL UPDATE using OleDBAdapter (C#)
- Can i do something international using which side of vb.net whether it is ado.net, we (VB.NET)
- Data Navigation in textboxes with ADO.NET (like ADO) (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: Use of DataGrid
- Next Thread: My first attempt at ASP.NET...


Hybrid Mode