473,545 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with OleDbParameter

Hi

I am trying to follow the walkthrough on MSDN
http://msdn.microsoft.com/library/en...InWebForms.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
OleDbParameterC ollection.
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.IndexOut OfRangeExceptio n: An OleDbParameter with
ParameterName 'categoryid' is not contained by this OleDbParameterC ollection.

Source Error:
Line 91: Categoryid = ddlCategoryID.S electedItem.Tex t
Line 92:
Line 93: cmdCategoriesBy ID.Parameters(" categoryid").Va lue = Categoryid
Line 94:
Line 95: OleDbConnection 1.Open()

Here is the full code for what I guess is the relevant bit:

Private Sub ddlCategoryID_S electedIndexCha nged(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
ddlCategoryID.S electedIndexCha nged

Dim Categoryid As String
Categoryid = ddlCategoryID.S electedItem.Tex t

cmdCategoriesBy ID.Parameters(" categoryid").Va lue = Categoryid

OleDbConnection 1.Open()
Dim dReader As System.Data.Ole Db.OleDbDataRea der
dreader = cmdCategoriesBy ID.ExecuteReade r(CommandBehavi or.SingleRow)
If dreader.Read() Then
txtCategoryName .Text = dreader(1)
txtCategoryDesc ription.Text = dreader(2)
End If
dreader.Close()
OleDbConnection 1.Close()

End Sub

Anyone have any thoughts on why it won't work?

Thanks.
--
one door shuts, another closes . .
Jul 21 '05 #1
6 2668
this:
cmdCategoriesBy ID.Parameters(" categoryid").Va lue = Categoryid

should be this:
cmdCategoriesBy ID.Parameters(" @categoryid").V alue = Categoryid

Greg

"TattyMane bigpond.net.au> " <dale1229@<dele tethis> wrote in message
news:E1******** *************** ***********@mic rosoft.com...
Hi

I am trying to follow the walkthrough on MSDN :
http://msdn.microsoft.com/library/en...InWebForms.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
OleDbParameterC ollection.
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.IndexOut OfRangeExceptio n: An OleDbParameter with
ParameterName 'categoryid' is not contained by this
OleDbParameterC ollection.

Source Error:
Line 91: Categoryid = ddlCategoryID.S electedItem.Tex t
Line 92:
Line 93: cmdCategoriesBy ID.Parameters(" categoryid").Va lue =
Categoryid
Line 94:
Line 95: OleDbConnection 1.Open()

Here is the full code for what I guess is the relevant bit:

Private Sub ddlCategoryID_S electedIndexCha nged(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
ddlCategoryID.S electedIndexCha nged

Dim Categoryid As String
Categoryid = ddlCategoryID.S electedItem.Tex t

cmdCategoriesBy ID.Parameters(" categoryid").Va lue = Categoryid

OleDbConnection 1.Open()
Dim dReader As System.Data.Ole Db.OleDbDataRea der
dreader =
cmdCategoriesBy ID.ExecuteReade r(CommandBehavi or.SingleRow)
If dreader.Read() Then
txtCategoryName .Text = dreader(1)
txtCategoryDesc ription.Text = dreader(2)
End If
dreader.Close()
OleDbConnection 1.Close()

End Sub

Anyone have any thoughts on why it won't work?

Thanks.
--
one door shuts, another closes . .

Jul 21 '05 #2
Tatty,

Because there is already a message from Greg, I don't add more than the part
where you are talking about SQL server. Did you know that there is a free
SQL server online (very stripped) it has limits, however for testing it is
very fine, it acts basicly the same as SQL server.

It is a hell of a job to install it when your computer uses not Strongly
Typed Password and as well the route to use it in an aspnet environment is
the same hell.

There is told that this will be fore the next version better.

http://www.microsoft.com/downloads/d...DisplayLang=en
http://msdn.microsoft.com/library/de...eddingmsde.asp
http://www.informit.com/isapi/produc...t/articlex.asp
I hope this helps a little bit?

Cor
Jul 21 '05 #3
Greg:

Thanks. However, if I try to use the '@' in the query builder , I get an
error: 'data type error in expression. It will only allow '=categoryid'.
ie:
SELECT CategoryID, CategoryName, Description
FROM Categories
WHERE (CategoryID = CategoryID)

If I use the '@categorid' in the code, I get the same error as before.
Apparentlythe "@" prefix is required for SQL Server named parameters.

?

David

"Greg Burns" wrote:
this:
cmdCategoriesBy ID.Parameters(" categoryid").Va lue = Categoryid

should be this:
cmdCategoriesBy ID.Parameters(" @categoryid").V alue = Categoryid

Greg

"TattyMane bigpond.net.au> " <dale1229@<dele tethis> wrote in message
news:E1******** *************** ***********@mic rosoft.com...
Hi

I am trying to follow the walkthrough on MSDN :
http://msdn.microsoft.com/library/en...InWebForms.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
OleDbParameterC ollection.
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.IndexOut OfRangeExceptio n: An OleDbParameter with
ParameterName 'categoryid' is not contained by this
OleDbParameterC ollection.

Source Error:
Line 91: Categoryid = ddlCategoryID.S electedItem.Tex t
Line 92:
Line 93: cmdCategoriesBy ID.Parameters(" categoryid").Va lue =
Categoryid
Line 94:
Line 95: OleDbConnection 1.Open()

Here is the full code for what I guess is the relevant bit:

Private Sub ddlCategoryID_S electedIndexCha nged(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
ddlCategoryID.S electedIndexCha nged

Dim Categoryid As String
Categoryid = ddlCategoryID.S electedItem.Tex t

cmdCategoriesBy ID.Parameters(" categoryid").Va lue = Categoryid

OleDbConnection 1.Open()
Dim dReader As System.Data.Ole Db.OleDbDataRea der
dreader =
cmdCategoriesBy ID.ExecuteReade r(CommandBehavi or.SingleRow)
If dreader.Read() Then
txtCategoryName .Text = dreader(1)
txtCategoryDesc ription.Text = dreader(2)
End If
dreader.Close()
OleDbConnection 1.Close()

End Sub

Anyone have any thoughts on why it won't work?

Thanks.
--
one door shuts, another closes . .


Jul 21 '05 #4
Thanks Cor.

I had a SQLExpress up but not running: a TCP/IP problem apparently. When I
(maybe) fixed that, it would not re-install. I shall try the download you've
suggested.

David

"Cor Ligthert" wrote:
Tatty,

Because there is already a message from Greg, I don't add more than the part
where you are talking about SQL server. Did you know that there is a free
SQL server online (very stripped) it has limits, however for testing it is
very fine, it acts basicly the same as SQL server.

It is a hell of a job to install it when your computer uses not Strongly
Typed Password and as well the route to use it in an aspnet environment is
the same hell.

There is told that this will be fore the next version better.

http://www.microsoft.com/downloads/d...DisplayLang=en
http://msdn.microsoft.com/library/de...eddingmsde.asp
http://www.informit.com/isapi/produc...t/articlex.asp
I hope this helps a little bit?

Cor

Jul 21 '05 #5
Tatty,

There are two desctiptions of the OleDb parameter on MSDN, this one is what
you get in a normal search

http://msdn.microsoft.com/library/de...classtopic.asp

This one is as it should be in my opinion

http://msdn.microsoft.com/library/de...eterstopic.asp

I hope this helps?

Cor
Jul 21 '05 #6
Cor

'fraid not - probably because I have too little understanding of the subject
matter. I shall try the SQL server download and hopefully that will work.

thanks once again.

David.

"Cor Ligthert" wrote:
Tatty,

There are two desctiptions of the OleDb parameter on MSDN, this one is what
you get in a normal search

http://msdn.microsoft.com/library/de...classtopic.asp

This one is as it should be in my opinion

http://msdn.microsoft.com/library/de...eterstopic.asp

I hope this helps?

Cor

Jul 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7789
by: NS | last post by:
Hi, I am trying to execute a prepare statement using oledb provider for DB2. The command.Prepare() statement is giving me an exception " No error information available: DB_E_NOCOMMAND(0x80040E0C)." My code is very simple and is working with other oledb provider, like SQL Server and oracle.
2
1602
by: ddaniel | last post by:
I have read many posts and seen many papers on the different techniques for sort and filtering datagrids. Many do re-queries against the dB ala Fritz Onion. I am trying to leverage the Dataview. The following control simply responds to a sort request and/or a pageing reqeust with an empty table (header only). Any ideas ? Code behind : ...
3
1567
by: Shapper | last post by:
Hello, I need to add a new record to an ACCESS database. I get the error: Syntax error in INSERT INTO statement. I have no idea what am I doing wrong. This is my code: ' Set Connection Dim connectionString As String = AppSettings("connectionString")
2
1303
by: Shapper | last post by:
Hello, I am trying to insert a record in an Access database using Asp.Net/Vb.Net. I am getting the error: "Operation must use an updateable query." How can I solve this problem? The code I am using is:
0
1084
by: Evandro Klen S. Azeredo | last post by:
Hi, I'm with the folowing problem: I have two tables: header(id_header) and Itens(id_header, id_item). When I insert data in Itens table, this error is returned: "You cannot add or change a record because a related record is required in table 'header'." I'm using MS Access database.
0
1202
by: B-lv | last post by:
I have an admin script to modify data in an Access db, but when I hit the update button after changing a field, I get a "Specified argument was out of the range of valid values. Parameter name: index" error at the line where I'm declaring my 'phone' variable. This subroutine worked with another table I was working with , but I'm wondering why...
2
2915
by: explode | last post by:
I made nova oledbdataadapter select update insert and delete command and connection veza. dataset is Studenti1data, I made it by the new data source wizard,and made datagridview and bindingsource draging Table1 to Form2. The select command works fine, but when I change the data and call update command I get a syntax error: ...
5
2147
by: explode | last post by:
I made a procedure Public Sub Novo(ByVal nova1 As String, ByVal nova2 As String) that creates a new oledbDataAdapter with insert update select and delete commads. I also added that commands can change depending how many columns are in a Table. I add a new column with this code: Private Sub Button4_Click(ByVal sender As System.Object, ByVal...
1
1450
by: chonthy | last post by:
Hello! I'm in trouble with the ASP.NET and OLEDB.JET connector. When I put the data into an XLS file from a dataset of my webpage, everything's OK, but in the destination file there is an apostrophe in front of every numeric data. It's problem for me, because there are some aritmethical operation with my datas in the XLS. Here is my source...
2
2110
by: Benedictum | last post by:
I have the following code that derives the value from a query string - // the code -> protected void Page_Load(object sender, EventArgs e) { string theTime = Request.QueryString; string altitude = Request.QueryString;
0
7484
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7415
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7928
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7440
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5344
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4963
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3451
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1902
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
726
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.