473,473 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problme using nullable parameters from vb.net

Hi

vb2005/sqlserver2005. I have a stored procedure that accepts three optional
parameters. If I run the following it returns the data fine;

DECLARE @return_value int
EXEC @return_value = [dbo].[NewSelectCommand]
@CompanyType = NULL,
@Status = NULL,
@BusinessDivision = NULL

If however I use the following in my vb.net app, I get nothing.

Me.CompaniesTableAdapter.Fill(Me.EMSDataSet.Compan ies,
DBNull.Value.ToString, DBNull.Value.ToString, DBNull.Value.ToString)

What is the problem and how can I fix it?

Thanks

Regards
Nov 21 '05 #1
4 1912
Try using System.Data.SqlTypes.SqlString.Null for your parameter values. If
your parameters are not strings there are additional types in the SqlTypes
namespace for the different SQL data types.

--
Thanks
Dan Jurden
"John" wrote:
Hi

vb2005/sqlserver2005. I have a stored procedure that accepts three optional
parameters. If I run the following it returns the data fine;

DECLARE @return_value int
EXEC @return_value = [dbo].[NewSelectCommand]
@CompanyType = NULL,
@Status = NULL,
@BusinessDivision = NULL

If however I use the following in my vb.net app, I get nothing.

Me.CompaniesTableAdapter.Fill(Me.EMSDataSet.Compan ies,
DBNull.Value.ToString, DBNull.Value.ToString, DBNull.Value.ToString)

What is the problem and how can I fix it?

Thanks

Regards

Nov 21 '05 #2
Hi

You have posted to a large number of groups which may not be appreciated if
they are not relivant. SQL 2005 questions should be posted to the SQL 2005
newsgroup see http://communities.microsoft.com/new...s/default.asp?

You may want to also check out:
http://support.microsoft.com/default...b;en-us;267588
http://support.microsoft.com/default...b;en-us;269541
http://support.microsoft.com/default...b;en-us;811889

John

"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi

vb2005/sqlserver2005. I have a stored procedure that accepts three
optional parameters. If I run the following it returns the data fine;

DECLARE @return_value int
EXEC @return_value = [dbo].[NewSelectCommand]
@CompanyType = NULL,
@Status = NULL,
@BusinessDivision = NULL

If however I use the following in my vb.net app, I get nothing.

Me.CompaniesTableAdapter.Fill(Me.EMSDataSet.Compan ies,
DBNull.Value.ToString, DBNull.Value.ToString, DBNull.Value.ToString)

What is the problem and how can I fix it?

Thanks

Regards

Nov 21 '05 #3
John,

I cannot find the method you are using so if you have documentation about
that please show us. In VB2003 is this in my opinion the most simple method
to use with parameters.

http://www.windowsformsdatagridhelp....6-7139b8970071

I hope this helps,

Cor
Nov 21 '05 #4
John (Jo**@nospam.infovis.co.uk) writes:
vb2005/sqlserver2005. I have a stored procedure that accepts three
optional parameters. If I run the following it returns the data fine;

DECLARE @return_value int
EXEC @return_value = [dbo].[NewSelectCommand]
@CompanyType = NULL,
@Status = NULL,
@BusinessDivision = NULL

If however I use the following in my vb.net app, I get nothing.

Me.CompaniesTableAdapter.Fill(Me.EMSDataSet.Compan ies,
DBNull.Value.ToString, DBNull.Value.ToString, DBNull.Value.ToString)

What is the problem and how can I fix it?


I don't really know what DBNull.Value.ToString() returns, but it is
not likely to be a NULL value. My guess goes for the string "NULL" which
is something completely different.

In any case, you desperately need to be more discriminate in your selection
of newsgroups, or else people will grew tired of you quickly.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Nov 21 '05 #5

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

Similar topics

4
by: ESPNSTI | last post by:
Hi, Please don't shoot me if the answer is simple, I'm new to .Net and C# :) .. I'm attempting to convert a nullable type to it's "non-nullable" type in a generic way (without knowing what...
4
by: Mark Rae | last post by:
Hi, In v1.1 I used to simulate nullable datatypes with structs. e.g. public struct NullableString { private readonly String pstrValue; private readonly bool blnHasValue; public...
1
by: Joe Bloggs | last post by:
Hi, Can someone please kindly show me how to determine if a type (read value type) is Nullable. MSDN has this KB: How to: Identify a Nullable Type (C# Programming Guide)...
0
by: rascal_mon | last post by:
I'm new with XML. Please give me some advice. I wonder there are any difference between XML that is automatically generated from ADO and XML file that shows in many textbooks. I found that the...
9
by: MLM450 | last post by:
Is there a way to get the address of the underlying value of a nullable variable without copying the value? I tried the following, but the compiler doesn't like it. I need to do this because I am...
3
by: Goofy | last post by:
The 2.0 Framework has a new type called System.Nullable. This allows something to Not exist, basically you can pass 'Nothing' to a method whose parameters as System.Nullable. Im looking at table...
6
by: =?Utf-8?B?VGVycnk=?= | last post by:
I have a generic function I am using to check constraints, an example of which is the following: Public Function ValidateMinValue(Of t As IComparable)(ByVal PropertyName As String, ByVal value...
3
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
I have a start and end date in my application. If a user does not know their dates yet, I want them, they will be null in the DB and I want them to be blank in the application. So, I'm trying to...
2
by: Tony Johansson | last post by:
Hello! These two declarations(1 and 2) are the same I assume. 1. System.Nullable<intnullable; 2. System.Nullable<intnullable = new System.Nullable<int(); So because these 1 and 2 are the...
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
1
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: 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.