G
Guest
Hi
I am trying to follow the walkthrough on MSDN
http://msdn.microsoft.com/library/e...ingDataUsingDatabaseUpdateQueryInWebForms.asp
however, as I do not have a working version of SQL server available (which
is another story . . ) I have tried to modify the code to use OLEconnection
and OLECommand with the Jet 4.0 data link provider.
The connection seems to work OK - the page loads with the first record of
the dataset. However when I select the category ID of any other item, I get
this error:
An OleDbParameter with ParameterName 'categoryid' is not contained by this
OleDbParameterCollection.
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.IndexOutOfRangeException: An OleDbParameter with
ParameterName 'categoryid' is not contained by this OleDbParameterCollection.
Source Error:
Line 91: Categoryid = ddlCategoryID.SelectedItem.Text
Line 92:
Line 93: cmdCategoriesByID.Parameters("categoryid").Value = Categoryid
Line 94:
Line 95: OleDbConnection1.Open()
Here is the full code for what I guess is the relevant bit:
Private Sub ddlCategoryID_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ddlCategoryID.SelectedIndexChanged
Dim Categoryid As String
Categoryid = ddlCategoryID.SelectedItem.Text
cmdCategoriesByID.Parameters("categoryid").Value = Categoryid
OleDbConnection1.Open()
Dim dReader As System.Data.OleDb.OleDbDataReader
dreader = cmdCategoriesByID.ExecuteReader(CommandBehavior.SingleRow)
If dreader.Read() Then
txtCategoryName.Text = dreader(1)
txtCategoryDescription.Text = dreader(2)
End If
dreader.Close()
OleDbConnection1.Close()
End Sub
Anyone have any thoughts on why it won't work?
Thanks.
I am trying to follow the walkthrough on MSDN
http://msdn.microsoft.com/library/e...ingDataUsingDatabaseUpdateQueryInWebForms.asp
however, as I do not have a working version of SQL server available (which
is another story . . ) I have tried to modify the code to use OLEconnection
and OLECommand with the Jet 4.0 data link provider.
The connection seems to work OK - the page loads with the first record of
the dataset. However when I select the category ID of any other item, I get
this error:
An OleDbParameter with ParameterName 'categoryid' is not contained by this
OleDbParameterCollection.
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.IndexOutOfRangeException: An OleDbParameter with
ParameterName 'categoryid' is not contained by this OleDbParameterCollection.
Source Error:
Line 91: Categoryid = ddlCategoryID.SelectedItem.Text
Line 92:
Line 93: cmdCategoriesByID.Parameters("categoryid").Value = Categoryid
Line 94:
Line 95: OleDbConnection1.Open()
Here is the full code for what I guess is the relevant bit:
Private Sub ddlCategoryID_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ddlCategoryID.SelectedIndexChanged
Dim Categoryid As String
Categoryid = ddlCategoryID.SelectedItem.Text
cmdCategoriesByID.Parameters("categoryid").Value = Categoryid
OleDbConnection1.Open()
Dim dReader As System.Data.OleDb.OleDbDataReader
dreader = cmdCategoriesByID.ExecuteReader(CommandBehavior.SingleRow)
If dreader.Read() Then
txtCategoryName.Text = dreader(1)
txtCategoryDescription.Text = dreader(2)
End If
dreader.Close()
OleDbConnection1.Close()
End Sub
Anyone have any thoughts on why it won't work?
Thanks.