473,698 Members | 2,972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

RG
OleDbCommand.Pr epare 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.Pr epare 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 = "myFirstReg ion"
....
' Create and prepare an SQL statement.
command.Command Text = "insert into Region (RegionID, RegionDescripti on)
values (@id, @desc)"
command.Paramet ers.Add("@id", id)
command.Paramet ers.Add("@desc" , desc)
command.Prepare () ' Calling Prepare after having set the Commandtext and
parameters.
command.Execute NonQuery()
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 2684

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

Similar topics

0
2092
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 StringBuffer(15) Regards, Philippe
0
3736
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. The code worked perfectly well on NT 4 w/ SQL Server 2000. Running the same code on Windows 2003 produces the following error: The operation could not be performed because the OLE DB provider 'SQLOLEDB' was unable to begin a distributed...
0
464
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. Everything worked properly since I was installed the new version on Microsoft Office 2003. Of cause, I rebuild assemblies and tried to connect. I got an error on Excel execution. When I opened source code to fix it, I found that there are no Workbooks and...
1
14236
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 cases as the sole argument of a scalar function". The parameter marker is used in the UCASE function. Is this such "some case"?? The full error provided by Clarion's trace:
0
1813
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 in the constructor of my UserControl to implement double buffering: // Enable double buffering this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint,
0
1329
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 tried to add a new dataset "The daVinci Diagram Surface could not be found. Please reinstall Visual Studio".
1
1982
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 and kicking) 3) .NET Framework v1.1.4322 (updated by Windows update) 4) My application running on d:\myapp directory (not c:\Inetpub)
2
1108
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
5651
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 basis to the user click the data in the column i m passing the Query String also to opening page......i have done that work through the datagrid hyperlink column control but the problem was that i cant pass the Querystring to it so that why i m using...
0
8683
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8611
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8876
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7741
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6531
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.