Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Gridview NULL criteria not showing
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
OS:
Windows XP SP2
Network:
Windows NT
Database:
Visual FoxPro
Divers
Thread ID:
01498857
Message ID:
01500658
Vues:
34
>>Naomi,
>>
>>I have finally gotten back to trying out your suggestion. I have integrated the code from the message you linked below into the "OnSelecting" attribute of the datasource in question as follows:
>>
>>
>> protected void SqlEquip_Selecting(object sender, SqlDataSourceCommandEventArgs e)
>>    {
>>
>>        SqlParameterCollection myCollection = (SqlParameterCollection)e.Command.Parameters;
>>
>>        IEnumerator ie = myCollection.GetEnumerator();
>>        string strSQL = string.Empty;
>>        while ((ie.MoveNext()))
>>        {
>>            SqlParameter param = (SqlParameter)ie.Current;
>>            string strValue = string.Empty;
>>            if (param.Value == null)
>>            {
>>                strValue = "NULL";
>>            }
>>            else
>>            {
>>                strValue = param.Value.ToString();
>>                strSQL += param.ParameterName.ToString() + "=" + strValue + "<BR />";
>>            }
>>
>>        }
>>
>>        Response.Write(strSQL.ToString()); 
>>    }   
>> 
>>
>>
>>
>>and the "parsed parameters" for the stored procedure have the following values:
>>
>>		@upsino=%<BR />@sub_name=%<BR />@co_equipno=%<BR />@serial_no=%<BR />
>>
>>
>>This still doesn't tell me why records with a NULL value in any one of the last three fields are excluded from the result set. The sql command that is run from the stored procedure is listed below in our earlier post.
>>
>>Thank you so much.
>>
>>
>>
>>>>Unfortunately I am running SQL Server Express 2008 R2.
>>>>
>>>Took me a bit while to find this thread
>>>
>>>How to get printed SQL command that was passed Thread #1370295 Message #1370295
>>>
>>>In this thread I give a link to an answer by limno as how to get the command passed to SQL Server using only .NET code (when you don't have Profiler).
>>>
>>>Hope this helps.
>
>Looks like every single parameter has gotten a value of '%'. What is supposed to be returned in this case? Try running the same now in SSMS using % for each parameter.


Okay,, now that makes sense. When I set % as the value for each parameter in SSMS I'm getting the same results as in ASP. So, in my ASP code I am setting the "DefaultValue" attribute for each of these parameters of the SqlDataSource equal to %.

When I'm running this query in SSMS (and its working correctly), I am DECLARING the parameters like this

declare @upsino varchar(7) = '%'
declare @sub_name varchar(50) = null
declare @co_equipno varchar(50)=null
declare @serial_no varchar(30)=null

How to I properly do that in my ASP code? Do I do it in the ascx file or the code behind file? I have the source code for the SqlDataSource in an earlier post in this thread.

I'm getting closer, thank you.
Elgin Rogers
Epic Solutions
www.epicsolutions.net
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform