| | |
ADO.NET Specified cast is not valid
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2004
Posts: 6
Reputation:
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)
-Ryan Hoffman
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
.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:
Solved Threads: 0
•
•
•
•
Originally Posted by Tekmaven™
objConn as no variable type...?
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
![]() |
Similar Threads
- ADO.NET (C#)
- 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...
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax appliances asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn cac checkbox child class click compatible confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datagridviewcheckbox datalist deadlock deployment development dgv dialog dropdownmenu dynamic edit embeddingactivexcontrol feedback findcontrol flash flv form forms gridview homeedition hosting iframe iis javascript jquery list menu mono mssql multistepregistration nameisnotdeclared novell objects order problem ratings relationaldatabases rotatepage save search security serializesmo.table sessionvariables silverlight smartcard sql ssl suse textbox tracking treeview typeof unauthorized validatedate validation vb.net video virtualdirectory vista visual-studio visualstudio vs2008 web webarchitecture webdevelopemnt webdevelopment wizard xml





