472,779 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 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 4813
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: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.