473,396 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

OleDbCommand.Prepare error: Size of parameter (VB.NET 2003)

RG
OleDbCommand.Prepare error: Size of parameter (VB.NET 2003)

I need to do a SQL INSERT statement into an Access table, and I’d like to
use the exact technique described in the Help file example for
OleDbCommand.Prepare Method.

When I follow the example exactly I get the unhandled exception error message:

“OleDbCommand.Prepare Method requires all parameters to have an explicitly
set type”.

In the “Remarks” of the Help file it warns about this, saying:

Remarks
Before you call Prepare, specify the data type of each parameter in the
statement to be prepared. For each parameter that has a variable length data
type, you must set the Size property to the maximum size needed. Prepare
returns an error if these conditions are not met.
That’s nice, but I can’t understand HOW to indicate the size of the
parameters. I just got confused & lost trying to figure it out.

The example DOES NOT indicate any sizes, it just says:

Dim id As Integer = 20
Dim desc As String = "myFirstRegion"
....
' Create and prepare an SQL statement.
command.CommandText = "insert into Region (RegionID, RegionDescription)
values (@id, @desc)"
command.Parameters.Add("@id", id)
command.Parameters.Add("@desc", desc)
command.Prepare() ' Calling Prepare after having set the Commandtext and
parameters.
command.ExecuteNonQuery()
I even got the same error when I just tried using ONLY an Integer parameter
(such as ‘id’ above); and Integer is a fixed data type at 4 bytes, not
variable (like String).

This is exactly the technique I need to use in my application, so I’d
appreciate anyone’s insight into this.

Thanks.
--
RG
Nov 21 '05 #1
0 2665

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

Similar topics

0
by: pcouas | last post by:
Hi, Currtently My SOAP service use method with String parameter. But in fact my String size has always 15 caracters. Could i define a SOAP service with a limited string parameter like...
0
by: Gary | last post by:
All, I am experiencing an error using MSDTC with SQL Server 2000 on Windows 2003 server. The code in question is a stored procedure that does a query within a transaction using linked servers....
0
by: Igor | last post by:
Hi everyone! I have a program written on C# that works with Microsoft Excel application. I built it to work with Excel 2000. With runtime objects I created assemblies to connect to Excel....
1
by: Joost Kraaijeveld | last post by:
Hi all, In my application that is generated by Clarion an SQL0418N ("A statement contains a use of a parameter marker that is not valid.") occurs. In the explanation section it says "in some...
0
by: David Veeneman | last post by:
This post is for the Google archive and does not require a reply. I received an 'Invalid parameter used' error when trying to do double-buffering with the .Net SetStyles method. I used this code...
0
by: Susil Patro | last post by:
Hi all, I have installed Visual Studio dot net version 2003, in my machine. I opened a new project for developing an application related to crystal reports. I got the following error, while I...
1
by: RedEagle | last post by:
Hi all, I have the following problem with ASP.NET running on Windows 2003. My configuration is: 1) Windows 2003 Server Standard 2) ASP.NET running in IIS5 Isolation mode (aspnet_wp.exe is alive...
2
by: Chea Vichet | last post by:
help me! Could not delete from specified tables. with the follwing code why? thanks protected void Button1_Click(object sender, EventArgs e) {
1
by: khalid sohail | last post by:
hi everybody i want to pass the window size parameter to <asp:hyperlink> attribute Navige URL Property. tell me how to pass the parameter to it.....actually i want to open the new window on the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.