Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > DataSource failing with null integer parameter

Reply
Thread Tools

DataSource failing with null integer parameter

 
 
Assimalyst
Guest
Posts: n/a
 
      10-13-2006
Hi,

I am trying to create a search page using a number of fields, mostly
strings, one is an integer. That allows the user to use any combination
of the fields to search with.

I have a datasource configured using the asp.net (v2.0) tools and the
parameters are passed from controls to a stored procedure. I have set
default values for the strings to '%' and left the default for the
integer blank. When i test the query in configuration it works fine
with a blank integer. But when i run it in the webpage the datasource
returns null if the integer field is blank. I have checked this with
the following code:

protected void gvSearchResults_DataBound(object sender, EventArgs e)
{
DataView DV =
(DataView)this.DataSourceSearchResultsGV.Select(Da taSourceSelectArguments.Empty);
if (DV != null)
{
. . . .

If i remove the integer field from the query it all works fine, if i
enter an integer it works fine. So it seems to be some sort of issue
converting the blank textbox control text (that the integer is passed
from) for use in the datasource.

Any ideas how to fix this?

Here's the query:

@pkiBarcodeNumber varchar(,
@szFirstName varchar(24),
@szSurname varchar(40),
@szDateOfBirth varchar(,
@szPostcode varchar(

AS


SELECT pkiBarcodeNumber, szFirstName, szSurname, szDateOfBirth,
szPostcode
FROM tblApplicationForms
WHERE pkiBarcodeNumber = CASE WHEN @pkiBarcodeNumber IS NULL THEN
pkiBarcodeNumber ELSE @pkiBarcodeNumber END
AND szFirstName LIKE '%' + @szFirstName + '%'
AND szSurname LIKE '%' + @szSurname + '%'
AND szDateOfBirth LIKE '%' + @szDateOfBirth + '%'
AND szPostcode LIKE '%' + @szPostcode + '%'
ORDER BY pkiBarcodeNumber

Thanks

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL RS Report Parameter multivalue failing Ben ASP .Net 1 06-11-2007 07:55 AM
"stringObj == null" vs "stringObj.equals(null)", for null check?? qazmlp1209@rediffmail.com Java 5 03-29-2006 10:37 PM
DataGrid DataSource is null on postback Narshe ASP .Net 4 12-26-2005 04:37 PM
Can't get DataSource of a repeater, returns null Alan Silver ASP .Net 2 07-12-2005 01:57 PM
DBD/DBI failing to add a blank in a non-null field dn_perl@hotmail.com Perl Misc 1 12-30-2004 01:37 AM



Advertisments