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

Home Posts Topics Members FAQ

Problem with null parameter

Hi

I have a datadapter with the following SQL;

SELECT ID, Company, Status, CompanyType
FROM Companies
WHERE (@Status IS NULL or @Status = Status)

When I try to fill like so;
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, "Current"), it brings all
companies with status Current.

The problem is that when I fill using
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, DBNull.Value.tostring) to
bring all companies regardless of status, then instead of getting all
companies I get nothing. How can I get this fixed?

Thanks

Regards
Nov 21 '05 #1
17 1527
John <Jo**@nospam.infovis.co.uk> wrote:
I have a datadapter with the following SQL;

SELECT ID, Company, Status, CompanyType
FROM Companies
WHERE (@Status IS NULL or @Status = Status)

When I try to fill like so;
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, "Current"), it brings all
companies with status Current.

The problem is that when I fill using
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, DBNull.Value.tostring) to
bring all companies regardless of status, then instead of getting all
companies I get nothing. How can I get this fixed?


Well, it's doing exactly what you've asked it to. When @Status is null,
your WHERE clause is:

WHERE (NULL IS NULL OR NULL = Status)

Now, the second clause is obviously never true - but the first one is
*always* true!
I *suspect* you meant:

WHERE (@Status IS NULL AND Status IS NULL) OR (@Status=Status)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 21 '05 #2

I *am* looking for the clause WHERE (NULL IS NULL OR NULL = Status) so that
it is true for when null value is sent for @status and brings back all
records. Problem is it is returning none!

Thanks

Regards

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP***********************@msnews.microsoft.co m...
John <Jo**@nospam.infovis.co.uk> wrote:
I have a datadapter with the following SQL;

SELECT ID, Company, Status, CompanyType
FROM Companies
WHERE (@Status IS NULL or @Status = Status)

When I try to fill like so;
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, "Current"), it brings
all
companies with status Current.

The problem is that when I fill using
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, DBNull.Value.tostring)
to
bring all companies regardless of status, then instead of getting all
companies I get nothing. How can I get this fixed?


Well, it's doing exactly what you've asked it to. When @Status is null,
your WHERE clause is:

WHERE (NULL IS NULL OR NULL = Status)

Now, the second clause is obviously never true - but the first one is
*always* true!
I *suspect* you meant:

WHERE (@Status IS NULL AND Status IS NULL) OR (@Status=Status)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Nov 21 '05 #3
John <Jo**@nospam.infovis.co.uk> wrote:
I *am* looking for the clause WHERE (NULL IS NULL OR NULL = Status) so that
it is true for when null value is sent for @status and brings back all
records. Problem is it is returning none!


I do apologise - I misread your previous post.

Hmm - have you put a profiler onto SQL Server to check what value is
actually being submitted in the query? I'm afraid I can't easily test
it myself at the moment.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 21 '05 #4
How does one run profiler from within vs2005?

Thanks

Regards
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
John <Jo**@nospam.infovis.co.uk> wrote:
I *am* looking for the clause WHERE (NULL IS NULL OR NULL = Status) so
that
it is true for when null value is sent for @status and brings back all
records. Problem is it is returning none!


I do apologise - I misread your previous post.

Hmm - have you put a profiler onto SQL Server to check what value is
actually being submitted in the query? I'm afraid I can't easily test
it myself at the moment.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Nov 21 '05 #5
John <Jo**@nospam.infovis.co.uk> wrote:
How does one run profiler from within vs2005?


Sorry, I don't mean a .NET profiler - I mean a SQL profiler. Just run
it up separately against the SQL database you're sending the query to,
and you should see the query including its parameters.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 21 '05 #6
The profiler shows that if I use this fill statement
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, DBNull.Value.tostring),
then status is passed as a 0 length string (@Status=N'').

If I use Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, DBNull.Value)
then I get the error "Value of type 'System.DBNull' cannot be converted to
'String'.".

So what should I do to get NULL value for @status at sql server level?

Thanks

Regards
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP***********************@msnews.microsoft.co m...
John <Jo**@nospam.infovis.co.uk> wrote:
How does one run profiler from within vs2005?


Sorry, I don't mean a .NET profiler - I mean a SQL profiler. Just run
it up separately against the SQL database you're sending the query to,
and you should see the query including its parameters.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Nov 21 '05 #7
I am qite confused here:

you used one of the overload DataAdapter.Fill() method that takes two
paramters( second on is a string), so it must be:

DataAdapter.Fill(DateSet, string)

Assume Me.MyDataSet.Cliets IS a DataSet (it looks like a DataTable to me,
though), the string parameter should be the mapped DataTable name in the
DataSet.

So, following code

"Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clie nts, "Current") "

fills data into a mapped DataTablcalled "Current" in the DatSet. while the
code

"Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clie nts, DBNull.Value.tostring) "

fills data into a mapped DataTable called "".

Obviously, regardless whether your "SELECT..." statement is correct or not,
the data (if they get retrieved from database) are filled into different
tables in the DataSet

However, if Me.MyDataSet.Clients is a DataTable, I wondered why you did not
get a "Type mismatch" error, since you passed wrong type to the overloaded
Fill() method. Did i misunderstand something here?
"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:eQ**************@TK2MSFTNGP09.phx.gbl...
Hi

I have a datadapter with the following SQL;

SELECT ID, Company, Status, CompanyType
FROM Companies
WHERE (@Status IS NULL or @Status = Status)

When I try to fill like so;
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, "Current"), it brings
all companies with status Current.

The problem is that when I fill using
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, DBNull.Value.tostring)
to bring all companies regardless of status, then instead of getting all
companies I get nothing. How can I get this fixed?

Thanks

Regards

Nov 21 '05 #8
John <Jo**@nospam.infovis.co.uk> wrote:
The profiler shows that if I use this fill statement
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, DBNull.Value.tostring),
then status is passed as a 0 length string (@Status=N'').
That's understandable - converting it to a string would indeed do that.
If I use Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, DBNull.Value)
then I get the error "Value of type 'System.DBNull' cannot be converted to
'String'.".

So what should I do to get NULL value for @status at sql server

level?

Have you tried passing in a straight null reference?

To be honest, I'm far from an ADO.NET expert, but that's really where
you need to be asking, I think. I've trimmed the follow-ups to this
post appropriately.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 21 '05 #9
Just a stab at it here, but you're converting your DBNull.Value to a string
before passing it in? How about if you just pass DBNull.Value in. I don't
even know what the DBNull.Value.ToString() would return; presumably a
Zero-Length String, but I've never used that before so I'm not sure. That
would make sense, since the only thing returned would be rows in which
@Status = ''. Presumably you don't have any statuses with ZLS' in them...
If you can, try changing a single row's status to a ZLS and run your second
query again. If DBNull.Value.ToString() is being passed in as a ZLS you
should get that one row back.

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

I have a datadapter with the following SQL;

SELECT ID, Company, Status, CompanyType
FROM Companies
WHERE (@Status IS NULL or @Status = Status)

When I try to fill like so;
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, "Current"), it brings
all companies with status Current.

The problem is that when I fill using
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, DBNull.Value.tostring)
to bring all companies regardless of status, then instead of getting all
companies I get nothing. How can I get this fixed?

Thanks

Regards

Nov 21 '05 #10
The profiler shows that if I use DBNull.Value.tostring then status is passed
as a 0 length string (@Status=N''), as you have said.

If I use DBNull.Value then I get the error "Value of type 'System.DBNull'
cannot be converted to 'String'.".

So what should I do to get NULL value for @status at sql server level?

Thanks

Regards

"Michael C#" <xy*@abcdef.com> wrote in message
news:QF******************@fe12.lga...
Just a stab at it here, but you're converting your DBNull.Value to a
string before passing it in? How about if you just pass DBNull.Value in.
I don't even know what the DBNull.Value.ToString() would return;
presumably a Zero-Length String, but I've never used that before so I'm
not sure. That would make sense, since the only thing returned would be
rows in which @Status = ''. Presumably you don't have any statuses with
ZLS' in them... If you can, try changing a single row's status to a ZLS
and run your second query again. If DBNull.Value.ToString() is being
passed in as a ZLS you should get that one row back.

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

I have a datadapter with the following SQL;

SELECT ID, Company, Status, CompanyType
FROM Companies
WHERE (@Status IS NULL or @Status = Status)

When I try to fill like so;
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, "Current"), it brings
all companies with status Current.

The problem is that when I fill using
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, DBNull.Value.tostring)
to bring all companies regardless of status, then instead of getting all
companies I get nothing. How can I get this fixed?

Thanks

Regards


Nov 21 '05 #11
Just curious... is the Status field in your table set to allow Null values?
"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:OK**************@TK2MSFTNGP10.phx.gbl...
The profiler shows that if I use DBNull.Value.tostring then status is
passed as a 0 length string (@Status=N''), as you have said.

If I use DBNull.Value then I get the error "Value of type 'System.DBNull'
cannot be converted to 'String'.".

So what should I do to get NULL value for @status at sql server level?

Thanks

Regards

"Michael C#" <xy*@abcdef.com> wrote in message
news:QF******************@fe12.lga...
Just a stab at it here, but you're converting your DBNull.Value to a
string before passing it in? How about if you just pass DBNull.Value in.
I don't even know what the DBNull.Value.ToString() would return;
presumably a Zero-Length String, but I've never used that before so I'm
not sure. That would make sense, since the only thing returned would be
rows in which @Status = ''. Presumably you don't have any statuses with
ZLS' in them... If you can, try changing a single row's status to a ZLS
and run your second query again. If DBNull.Value.ToString() is being
passed in as a ZLS you should get that one row back.

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

I have a datadapter with the following SQL;

SELECT ID, Company, Status, CompanyType
FROM Companies
WHERE (@Status IS NULL or @Status = Status)

When I try to fill like so;
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, "Current"), it brings
all companies with status Current.

The problem is that when I fill using
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, DBNull.Value.tostring)
to bring all companies regardless of status, then instead of getting all
companies I get nothing. How can I get this fixed?

Thanks

Regards



Nov 21 '05 #12
Hi,

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

I have a datadapter with the following SQL;

SELECT ID, Company, Status, CompanyType
FROM Companies
WHERE (@Status IS NULL or @Status = Status)

When I try to fill like so;
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, "Current"), it brings
all companies with status Current.

The problem is that when I fill using
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, DBNull.Value.tostring)
to bring all companies regardless of status, then instead of getting all
companies I get nothing. How can I get this fixed?
It looks like you are using the new TableAdapter generated by wizard in
VS2005, which is used if you drag table onto the Form.

The idea is to change the query you already have so that it gets all
records. Then *add* another query that filters on Status.

1. Open "DataSources" window ( Data -> Show Data Sources ).

2. Right click on the relevant DataSet ( MyDataSet ) and choose "Edit
DataSet with Designer".
Now you should visually see all your DataTables and TableAdapters, look for
the relevant TableAdapter (CompanyTableAdapter).

3. Under the relevant TableAdapter you should see a row with Fill, GetData.
Click on that row and then right click and choose properties. Then change
the CommandText of the query so that it uses SELECT * FROM Companies; or
make it use a stored procedure that does the same.

4. Right click on the relevant TableAdapter (CompanyTableAdapter) and choose
"Add Query".
Follow the wizard and make sure this time you're using a query like:
SELECT * FROM Companies WHERE Status = @Status;
! In the last step change FillBy to FillByStatus and change GetBy to
GetByStatus.
Now, you have two ways to fill your dataset:

' get all records
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients)

' get records status = current
Me.CompanyTableAdapter.FillByStatus(Me.MyDataSet.C lients, "Current")
HTH,
Greetings

Thanks

Regards

Nov 21 '05 #13
yes.

"Wicksy" <wi*****@nospam-yahoo.com> wrote in message
news:dh**********@news.freedom2surf.net...
Just curious... is the Status field in your table set to allow Null
values?
"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:OK**************@TK2MSFTNGP10.phx.gbl...
The profiler shows that if I use DBNull.Value.tostring then status is
passed as a 0 length string (@Status=N''), as you have said.

If I use DBNull.Value then I get the error "Value of type 'System.DBNull'
cannot be converted to 'String'.".

So what should I do to get NULL value for @status at sql server level?

Thanks

Regards

"Michael C#" <xy*@abcdef.com> wrote in message
news:QF******************@fe12.lga...
Just a stab at it here, but you're converting your DBNull.Value to a
string before passing it in? How about if you just pass DBNull.Value
in. I don't even know what the DBNull.Value.ToString() would return;
presumably a Zero-Length String, but I've never used that before so I'm
not sure. That would make sense, since the only thing returned would be
rows in which @Status = ''. Presumably you don't have any statuses with
ZLS' in them... If you can, try changing a single row's status to a ZLS
and run your second query again. If DBNull.Value.ToString() is being
passed in as a ZLS you should get that one row back.

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

I have a datadapter with the following SQL;

SELECT ID, Company, Status, CompanyType
FROM Companies
WHERE (@Status IS NULL or @Status = Status)

When I try to fill like so;
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, "Current"), it brings
all companies with status Current.

The problem is that when I fill using
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients,
DBNull.Value.tostring) to bring all companies regardless of status,
then instead of getting all companies I get nothing. How can I get this
fixed?

Thanks

Regards



Nov 21 '05 #14
Worked like magic! Thanks.

Regards

"Bart Mermuys" <bm*************@hotmail.com> wrote in message
news:uZ*************@tk2msftngp13.phx.gbl...
Hi,

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

I have a datadapter with the following SQL;

SELECT ID, Company, Status, CompanyType
FROM Companies
WHERE (@Status IS NULL or @Status = Status)

When I try to fill like so;
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, "Current"), it brings
all companies with status Current.

The problem is that when I fill using
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, DBNull.Value.tostring)
to bring all companies regardless of status, then instead of getting all
companies I get nothing. How can I get this fixed?


It looks like you are using the new TableAdapter generated by wizard in
VS2005, which is used if you drag table onto the Form.

The idea is to change the query you already have so that it gets all
records. Then *add* another query that filters on Status.

1. Open "DataSources" window ( Data -> Show Data Sources ).

2. Right click on the relevant DataSet ( MyDataSet ) and choose "Edit
DataSet with Designer".
Now you should visually see all your DataTables and TableAdapters, look
for the relevant TableAdapter (CompanyTableAdapter).

3. Under the relevant TableAdapter you should see a row with Fill,
GetData.
Click on that row and then right click and choose properties. Then change
the CommandText of the query so that it uses SELECT * FROM Companies; or
make it use a stored procedure that does the same.

4. Right click on the relevant TableAdapter (CompanyTableAdapter) and
choose "Add Query".
Follow the wizard and make sure this time you're using a query like:
SELECT * FROM Companies WHERE Status = @Status;
! In the last step change FillBy to FillByStatus and change GetBy to
GetByStatus.
Now, you have two ways to fill your dataset:

' get all records
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients)

' get records status = current
Me.CompanyTableAdapter.FillByStatus(Me.MyDataSet.C lients, "Current")
HTH,
Greetings

Thanks

Regards


Nov 21 '05 #15
I would need to see more of your code, but off the top of my head I would
set the @Status parameter on your query to the proper value without
converting DBNull.Value to a string. That, or pass in a value you'll never
use as a status, like maybe 'ZZ' or change the IS NULL to = ''.

WHERE (@Status = '' or @Status = Status)

"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:OK**************@TK2MSFTNGP10.phx.gbl...
The profiler shows that if I use DBNull.Value.tostring then status is
passed as a 0 length string (@Status=N''), as you have said.

If I use DBNull.Value then I get the error "Value of type 'System.DBNull'
cannot be converted to 'String'.".

So what should I do to get NULL value for @status at sql server level?

Thanks

Regards

"Michael C#" <xy*@abcdef.com> wrote in message
news:QF******************@fe12.lga...
Just a stab at it here, but you're converting your DBNull.Value to a
string before passing it in? How about if you just pass DBNull.Value in.
I don't even know what the DBNull.Value.ToString() would return;
presumably a Zero-Length String, but I've never used that before so I'm
not sure. That would make sense, since the only thing returned would be
rows in which @Status = ''. Presumably you don't have any statuses with
ZLS' in them... If you can, try changing a single row's status to a ZLS
and run your second query again. If DBNull.Value.ToString() is being
passed in as a ZLS you should get that one row back.

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

I have a datadapter with the following SQL;

SELECT ID, Company, Status, CompanyType
FROM Companies
WHERE (@Status IS NULL or @Status = Status)

When I try to fill like so;
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, "Current"), it brings
all companies with status Current.

The problem is that when I fill using
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, DBNull.Value.tostring)
to bring all companies regardless of status, then instead of getting all
companies I get nothing. How can I get this fixed?

Thanks

Regards



Nov 21 '05 #16
P.S. - Pls don't cross-post. Thx

"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:OK**************@TK2MSFTNGP10.phx.gbl...
The profiler shows that if I use DBNull.Value.tostring then status is
passed as a 0 length string (@Status=N''), as you have said.

If I use DBNull.Value then I get the error "Value of type 'System.DBNull'
cannot be converted to 'String'.".

So what should I do to get NULL value for @status at sql server level?

Thanks

Regards

"Michael C#" <xy*@abcdef.com> wrote in message
news:QF******************@fe12.lga...
Just a stab at it here, but you're converting your DBNull.Value to a
string before passing it in? How about if you just pass DBNull.Value in.
I don't even know what the DBNull.Value.ToString() would return;
presumably a Zero-Length String, but I've never used that before so I'm
not sure. That would make sense, since the only thing returned would be
rows in which @Status = ''. Presumably you don't have any statuses with
ZLS' in them... If you can, try changing a single row's status to a ZLS
and run your second query again. If DBNull.Value.ToString() is being
passed in as a ZLS you should get that one row back.

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

I have a datadapter with the following SQL;

SELECT ID, Company, Status, CompanyType
FROM Companies
WHERE (@Status IS NULL or @Status = Status)

When I try to fill like so;
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, "Current"), it brings
all companies with status Current.

The problem is that when I fill using
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, DBNull.Value.tostring)
to bring all companies regardless of status, then instead of getting all
companies I get nothing. How can I get this fixed?

Thanks

Regards



Nov 21 '05 #17
There is a solution by Bart in this thread which has worked for me. Seems
elegant too. Apparently you can have multiple select statements with
dataadapter in vs2005.

Regards

"Michael C#" <xy*@abcdef.com> wrote in message
news:Kp*****************@fe11.lga...
I would need to see more of your code, but off the top of my head I would
set the @Status parameter on your query to the proper value without
converting DBNull.Value to a string. That, or pass in a value you'll never
use as a status, like maybe 'ZZ' or change the IS NULL to = ''.

WHERE (@Status = '' or @Status = Status)

"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:OK**************@TK2MSFTNGP10.phx.gbl...
The profiler shows that if I use DBNull.Value.tostring then status is
passed as a 0 length string (@Status=N''), as you have said.

If I use DBNull.Value then I get the error "Value of type 'System.DBNull'
cannot be converted to 'String'.".

So what should I do to get NULL value for @status at sql server level?

Thanks

Regards

"Michael C#" <xy*@abcdef.com> wrote in message
news:QF******************@fe12.lga...
Just a stab at it here, but you're converting your DBNull.Value to a
string before passing it in? How about if you just pass DBNull.Value
in. I don't even know what the DBNull.Value.ToString() would return;
presumably a Zero-Length String, but I've never used that before so I'm
not sure. That would make sense, since the only thing returned would be
rows in which @Status = ''. Presumably you don't have any statuses with
ZLS' in them... If you can, try changing a single row's status to a ZLS
and run your second query again. If DBNull.Value.ToString() is being
passed in as a ZLS you should get that one row back.

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

I have a datadapter with the following SQL;

SELECT ID, Company, Status, CompanyType
FROM Companies
WHERE (@Status IS NULL or @Status = Status)

When I try to fill like so;
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients, "Current"), it brings
all companies with status Current.

The problem is that when I fill using
Me.CompanyTableAdapter.Fill(Me.MyDataSet.Clients,
DBNull.Value.tostring) to bring all companies regardless of status,
then instead of getting all companies I get nothing. How can I get this
fixed?

Thanks

Regards



Nov 21 '05 #18

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

Similar topics

4
by: Dani | last post by:
Hi everyone Description of the problem: Using a PreparedStatement to write down an integer (int) plus a timestamp for testing purposes. When read out again the integer looks very different. We...
4
by: Daniel | last post by:
Hello, i have an assembly which is developped in C#.NET. The assembly provides two classes, one class has a method which accepts an instance of the other class as a parameter, like this: ---...
5
by: Jason Huang | last post by:
Hi, The SqlParameter myPM =new SqlParameter("@Address", txtAddress.Text) is working for update, but SqlParameter myPM =new SqlParameter ("@Address",SqlDbType.NVarChar,90,txtAddress.Text) is...
5
by: Kevin Yu | last post by:
hi all since the DateTime can't be assign null, the min value is set to 1901 or something, if in a application design, the date field can be null, so in between the UI and the DB, the business...
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...
7
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function...
4
by: nishi57 | last post by:
I hope I can get some help regarding this issue, which has been going on for a while. I have a desktop user who is having problem running "Stored Procedures". The DB2 Connect application works fine...
4
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which -...
0
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
8
by: Martin Z | last post by:
INSERT INTO dbo.Transmission (TransmissionDate, TransmissionDirection, Filename, TransmittedData) VALUES (@TransmissionDate,@TransmissionDirection,@Filename,@TransmittedData); SELECT @retVal =...
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
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
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,...
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...
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: 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...
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.