473,464 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to set parameter to null

Gav
Hi all,

Having a little problem with parameters, I need to set a parameter to null
but I'm getting errors that I don't understand.

The code:

SqlParameter prmItemNumber= mycom.Parameters.Add(new
SqlParameter("@ItemNumber",SqlDbType.VarChar, 10));
prmItemNumber.set_IsNullable(true);
prmItemNumber.Value= (Convert.DBNull);

The error:

On build I get the error,
'System.Data.SqlClient.SqlParameter.IsNullable.set ': cannot explicitly call
operator or accessor

Can anyone help me with this please?

Thanks
Gav
Jul 21 '05 #1
2 4829
Why don't you say:

prmItemNumber.IsNullable = true;

"Gav" <sp**@spam.com> wrote in message
news:OR**************@TK2MSFTNGP15.phx.gbl...
Hi all,

Having a little problem with parameters, I need to set a parameter to null
but I'm getting errors that I don't understand.

The code:

SqlParameter prmItemNumber= mycom.Parameters.Add(new
SqlParameter("@ItemNumber",SqlDbType.VarChar, 10));
prmItemNumber.set_IsNullable(true);
prmItemNumber.Value= (Convert.DBNull);

The error:

On build I get the error,
'System.Data.SqlClient.SqlParameter.IsNullable.set ': cannot explicitly
call operator or accessor

Can anyone help me with this please?

Thanks
Gav

Jul 21 '05 #2
Gav
seems to work

thank you so much for that much appretiated
Gav

"Marina" <so*****@nospam.com> wrote in message
news:eg*************@TK2MSFTNGP12.phx.gbl...
Why don't you say:

prmItemNumber.IsNullable = true;

"Gav" <sp**@spam.com> wrote in message
news:OR**************@TK2MSFTNGP15.phx.gbl...
Hi all,

Having a little problem with parameters, I need to set a parameter to
null but I'm getting errors that I don't understand.

The code:

SqlParameter prmItemNumber= mycom.Parameters.Add(new
SqlParameter("@ItemNumber",SqlDbType.VarChar, 10));
prmItemNumber.set_IsNullable(true);
prmItemNumber.Value= (Convert.DBNull);

The error:

On build I get the error,
'System.Data.SqlClient.SqlParameter.IsNullable.set ': cannot explicitly
call operator or accessor

Can anyone help me with this please?

Thanks
Gav


Jul 21 '05 #3

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

Similar topics

4
by: Steven | last post by:
I'm calling a stored procedure which has an output parameter of type int. Once the stored procedure is executed, I want to check the value of the parameter in case it is null. However, when the a...
2
by: Chris Herring | last post by:
Hi there: Well, let me start off by saying that I am a Visual Studio drag and drop weenie, not a real programmer. So I tend to get confused when things do not look like the instructions said they...
4
by: js | last post by:
I have a stored procedure named "processInventory" like the following. Depending on the passed in parameters, I would like to add a WHERE clause for "select" action. For example, if any varchar...
16
by: Stefan Hong | last post by:
Hi, It seems that the way reflection resolves methods is not quite the same as default CLR. For example this simple class: class Test { public void Hello(string name) {...
2
by: PK | last post by:
Hi, I have an application that opens a Crystal report document and passes in a value to a parameter in the report (pointing to an Oracle DB). However, if I want to pass a "null" value to retrieve...
5
by: Jet | last post by:
Hi all, I had a code like the follow: class A{ ... public void get(int i,params OleDbParameter p) { if((p!=null)||(p.Length>0)) { // Do some work }
3
by: Ross McLean | last post by:
Hi all, I've been teaching myself C# for a new project at work. I have a bit of a background in c++ and java but never been what you could call a guru. I'm having some strange things happening...
19
by: George | last post by:
Hi all. How can I check and return an error on a constructor that receives a pointer as a parameter and the parameter is null. Is there any possibility to return an error? or do I have to create...
4
by: =?Utf-8?B?UHVjY2E=?= | last post by:
The function that I'm trying to call through DLLImport has a parameter that has a C code's vector's Itrator to a structure. I Have marshalled the structure in C# but how do I do the C type...
0
debasisdas
by: debasisdas | last post by:
The following sample code is designed to display the use of accepting a list of values in a single parameter and process the same in the where clause inside a procedure. STEP1:-First create an...
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
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
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...
0
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...
0
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 project—planning, coding, testing,...
0
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...
0
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...
0
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 ...

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.