473,320 Members | 1,572 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,320 software developers and data experts.

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 4825
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.