.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Passing a Null as Parameter fails

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :


I have a simple Stored Proc that has a single parameter passed.  If the parameter is Null the SP should return all records else it should return the record for the passed parameter.  BUT it fails on passing Null.  I have used the exact same format for other SP's which work fine, but never passing a Null.

Anyone got suggestions?

-- =============================================
-- Author:		<Phillip J Seaman>
-- Create date: <05/17/2011>
-- Description:	<Gets ALL Vessel names OR single By ID value>
-- =============================================
	-- Add the parameters for the stored procedure here
	@V_ID int = Null

View Complete Post

More Related Resource Links

ObjectDataSource CancelSelectOnNullParameter="false" // Select all when select parameter is null or


Hi ! I am using an objectdatasource in my project and I want to select all rows when the selectparameter value is empty ! I did the following but I am failling;
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DataObjectTypeName="TugberkUgurluCom_TransferModule.TransferPriceDetailsAll" SelectMethod="GetAllDataFromPricesForControl" TypeName="TugberkUgurluCom_TransferModule.TransferPriceDBComponent" UpdateMethod="UpdateTransferPrices">
    <asp:ControlParameter ConvertEmptyStringToNull="true" ControlID="DropDownList1" Name="TpDestID" PropertyName="SelectedValue" Type="

Passing Id in parameter


Hi, I am using url in my mvc application like /product/edit/5, should change it because users can

change id parameter and access different product as this Id directly refer to Id in product table, I have validation there for user to access product, what you suggest, what best practice can be for it ?

should I continue with it or should I change it as application has many users

Thanks you


SQL Null Insert fails

I am developing an SSIS package and trying to update an existing table with info from new columns.  In other words, this table already has records for my input CSV file.  But this CSV file has additional columns for these same records.  So I need to keep existing columns in table.  How can I achieve this? I began by using Import/Export Wizard and it did most of hard work for me.  But one of the columns previously defined in this table doesn't allow NULLs.  So although I want these new rows to map into existing table, it seems like this will just overwrite the table values and I get the error below.  How can I fix this? I have a Flat File CSV source, Data Conversoin, and DestinationConnectionOLEDB Error: 0xC0202009 at Data Flow Task 1, Destination - j5c_ALL_DATA2 [138]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "The statement has been terminated.". An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "Cannot insert the value NULL into column 'timestamp', table 'berkeley.dbo.j5c_ALL_DATA2'; column does not allow nulls. INSERT fails.". Error: 0xC0209029 at Data Flow Task 1, Destinati

ascx control with passing parameter

i want to create a ascx control with passing parameter .i got followong code from stackoverflow<% Html.RenderPartial("~/Views/Shared/MyControl.ascx", {data model object}) %>i am fine above line but how can i design html control for this.sample code example would be great.

Performance problem when passing a "nullable parameter"

Say @startDate and @endDate are my datetime parameters. If users does not want to limit the @startDate for example, he/she sends a null value to @startDate. Same goes for @endDate (and any other parameter). What I like doing: Select * From MyTable Where MyTable.Date >= IsNull(@startDate, MyTable.Date) And MyTable.Date <= IsNull(@endDate, MyTable.Date) The above looks nice as far as coding but when I look at the execution plan I'm surprised to see the my clustered index (that has it's first column as "MyTable.Date") is not used. instead I get an index scan. More frustrating is that the following works with an index seek and is much faster: Select * From MyTable Where MyTable.Date >= @startDate And MyTable.Date <= @endDate So what should I do? am I doing something wrong? I don't want to use dynamic sql because it's generally slower and prone to sql injection (is dynamic sql my only choise)? I don't want to use "if statements" because then i'd have to rewrite my code several times (in this case three combinations but some of my procedures have up to 8 "nullable" parameters). Or maybe there is another way of implementing what I call here "nullable parameters". obviously I preformance is crucial. thanks, Dror

SSRS 2008 Export to PDF fails for large data with System.Exception: Parameter is not valid

Hi, We are working on Range Bar Chart using SSRS 2008. The report has huge data. It is properly displaying the data, but when we tried to export to pdf it is failing with the following exception. Exporting to excel works fine. Also if the report has small/medium data it is property exporting to PDF. It is failing only in case of huge data (we have custom page size of 28" X 14"). Of course the report has lot of expressions we used to customize the colors/text as per our requirements.   Server Error in '/Reports_SQLDEV2008' Application. Parameter is not valid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Exception: Parameter is not valid. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:   [Exception: Parameter is not valid.]   [Exception: An error occurred during rendering of the report.]   [Exception: An error occurred during rendering of the report.]    Microsoft.Reporting.WebForms.ServerReport.ServerUrlRequest(Boolean isAbortable, String url, Stream ou

Response.Redirect in C# for page to page parameter passing

Looking for examples of this, but can't find anything specific. I'm new to ASP.NET, and C# at the same time... so I'm struggling to get it right...  Thanks, Nick

problem with passing parameter values to stored proceedure from asp.net c#

hi all, i am facing a problem while passing parameters to a stored proceedure. following is my sql query written for creating this stored procedure:   CREATE proc [dbo].[getstudent]( @wherecolumn nvarchar(2000), @wherevalue nvarchar(2000)) asbegin  declare @sql nvarchar(max) set @sql = 'select * from student2 where ' + @wherecolumn+'='+@wherevalueexec sp_Executesql @sql end   my table contains four columns: And the sql Query For the table is as follows:   CREATE TABLE [dbo].[student2]( [name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [rollno] [int] NOT NULL, [class] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [section] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, CONSTRAINT [PK_student2] PRIMARY KEY CLUSTERED ( [rollno] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]   from page behind I am passing the values to parameter as follows:   SqlCommand command = new SqlCommand("getstudent", c.con); SqlDataAdapter datadapter = new SqlDataAdapter(c.cmd); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@wherecolumn", SqlDbType.NVarChar).Value = "rollno"; command.Parameters.Add("@wherevalue", Sq

Parameter passing from masterreport to subreport

what If I'm passing a parameter which is null ?? and if the parameter is an integer? My subreport query is : SELECT    ...FROM ... WHERE ... and (CRMAF_FilteredContact.ownerid = @ownerid  OR @ownerid IS NULL) ORDER BY CRMAF_FilteredContact.OwnerIDname When I try it with a null value in the subreport, it works fine, but when I try it from  the main report, so I tried to remove the ownerid parameter, I tried to put it at blank, I tried to put NULL but I've always an error, the report start fine but then, on the total, i've the error "error subreport could not  be shown". I've the error : [rsErrorExecutingSubreport] An error occurred while executing the subreport subreport3: One or more parameters required to run the report have not been specified. But then I don't know how to fixe it.  I put the @ownerid as blank, but obviously it doesn't like it. I've done that because i'm using the same sub report above but grouping with this parameter. How can I manage this ? Thanks a lot,  

Passing parameter into Web Service

Hi, I'm creating a web service using C#, and wondering if it is possible to capture the parameter passed in from the URL?e.g. http://www.abc.com/webservice/service.asmx?para1=one&para2=twoIs there a function or something that can obtain the parameters like the normal Request.QueryString? Thanks in advance! Rgds

passing parameter using ODBC - mysql

Dear All, I'm having problem on passing parameter on odbc because it's not working at all.  I tried this using sql and I have no problem at all. All are working fine.  Is there a different syntax on odbc?  Here's my code: Private Sub BindDetails() ' Obtain the index of the selected row Dim selectedRowIndex As Integer = GridEmployee.SelectedIndex ' Read the employee ID Dim IDNumber As Integer = GridEmployee.DataKeys(selectedRowIndex).Value ' Define data objects Dim conn As OdbcConnection Dim comm As OdbcCommand Dim reader As OdbcDataReader Dim connectionString As String = _ ConfigurationManager.ConnectionStrings( _ "mysqlconn").ConnectionString ' Initialize connection conn = New OdbcConnection(connectionString) ' Create command comm = New OdbcCommand("SELECT employee.IDNumber, employee.EmployeeID, project.ProjectName, team.TeamName, employee.Username, employee.`Password`, employee.LastName, employee.FirstName, employee.MiddleName, employee.NickName, employee.EmailAddress, employee.DateHired, employee.LengthService, employee.RegularizationDate, employeestatus.EmployeeStatusName, employee.Birthdate, employee.Mobile1, employee.Mobile2, employee.Phone1, employee.Address, employee.Colleg

NULL label doesn't appear on drop down or multi-select parameter.

Hi, I am using SSRS 2005 SP3. I have the following query that I use for my parameter: SELECT 0 AS c1, 'NOT Specified' AS c2 UNION SELECT 1 AS c1, NULL AS c2 UNION SELECT 2 AS c1, 'Test 1' AS c2 UNION SELECT 3 AS c1, 'Test 2' AS c2 Let's call my parameter prm1. The type of prm1 is string and it has "Allow null value" and "Allow blank value" options ticked. C1 is the value field and C2 is the label field for prm1. When I preview the report, and I didn't see NULL in my drop down list,  but that record has been shown as 1 (which is the value). I am wondering if this is a normal behavior of SSRS? It's not a big deal. I can replace NULL with something else, but I am just curious. Cheers, Uzzie

SSRS 2005 Drillthrough chart Passing Wrong parameter value

Hi I have a drillthrough report that in Report A I have a week of data, showing Sunday through Saturday on the X-axis. When a data point is clicked on this chart, it shpuld pass the date of the weekday for that data point to Report B. But sometimes, it passes the prior weekday date, eg click on the Monday date data point, but Sunday's date is passed to the next report. Has anyone observed this type of behavior? I should mention that it is intermittent.   Thanks all.   Bobrpress

Passing multi values to another multi value parameter

Hi, my requirement is as follows I have a parameter1 in which i populate values from database. the user can select multiple values from parameter1. after the parameter1 i have another parameter2 which is also mutliselection value. i,e depending on the selection of parameter i need to populate remaining values in Parameter2 (which is also a multi selection value). i have splited the values from parameter1 and passed the value of parameter1 (parameter1.value) to parameter2. but i am getting the following error An expression of non-boolean type specified in a context where condition is expected, near ',' incorrect syntax near the keyword 'ELSE' can anyone help me in this Thanks, Rajesh Peethala

Executing an SSIS package from an stored procedure and passing a parameter to it:

Hello all, I'm trying to execute an SSIS package from an stored procedure, using xp_cmdshell. When I execute the package, hard coding the value on the variable, I get rows inserted to my destination tables, which indicates my package pulled the correct data based on the TransactionID parameter. When I execute the package from the stored procedure, the package executes without issues, but I get no rows inserted into my destination tables, which leads me to think it is a data type issue, between the package and the variables I'm using within the stored procedure. The variable TransactionID on the SSIS package, is a string data type, therefore I'm passing it as a varchar from the stored procedure. Am I doing this correctly? Maybe I'm missing something, can you guys see anything wrong? Also, I tried login into the server and executing these 2 commands on the cmd prompt: One with "" quotes between the TransactionID value: dtexec /FILE "D:\SSISPackages\MyOrderCheckProcess\MyOrderCheck_RenewalOrder.dtsx" /CONFIGFILE "D:\SSISPackages\MyOrderCheckProcess\MyOrderCheckProcess_Config.dtsConfig" /CHECKPOINTING OFF  /REPORTING EWCDI  /SET \Package.Variables[User::TransactionID].Properties[Value];"470219"   And also one without quotes between the TransactionID value: dtexec /FILE "D:\SSISPackages\MyOrderCheckProcess\MyOrde

SSRS problem with passing multiple parameter values via URL %2c

Hi, I have a problem with passing multiple parameter values from one report (A) to another report (B).   For example I built a URL string in report (A) with the parameters like &Parameter1=1&Parameter1=2. As soon as I click on that URL the URL parameters look like &Parameter1=1%2c2 and the parameters don’t getting populated on report (B).   If I change the parameter in the URL to &Parameter1=1&Parameter1=2 and execute the URL manual the parameter on report (B) getting populated properly.   Is there a way to disable the coding like %2c (comma) or is there another solution for it?   Thanks

rdlc report parameter passing

hi i am working on report project i am new in .net will some one help how to pass parameters in rdlc reports . the options for reprt parameter is not available in visual studio 2010 .Please help someone ..
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend