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

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

Value cannot be null. Parameter name: entity

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
BurnbetDataContext ctx = new BurnbetDataContext("data source=.\\SQLEXPRESS;Integrated Security=SSPI;" + "AttachDBFilename=|DataDirectory|\\BurnbetDatabase.mdf;User Instance=true"); tbl_Payment democustomer = ctx.tbl_Payments.SingleOrDefault(c => c.ID == 5); ctx.tbl_Payments.DeleteOnSubmit(democustomer); ctx.SubmitChanges(); If this information does not exist in the table displays this error:Value Can not BE null. Parameter name: EntityHow to solve this problem?

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="

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

Boolean Parameter to include null on selection on false

What i am trying to do is use a boolean parameter which when a user selects true only brings up true but when user selects false it brings up all nulls as well as false    Sample    Declare @Parameter1 boolean  Select  From example  Where field.1 = @Parameter1 (If parameter1 is false I want it to select all null fields as well as false)   Thanks   Michael 

page version history gives error: "value cannot be null. parameter key: name"

Hello, I'm have customized my homepage in SharePoint Designer 2010. I want to go back to a previous version, so I right click on the aspx file in sharepoint designer and choose "version history". When I do that I get this message: There was an error connecting to the server. The server error encountered is "Value cannot be null. Parameter name: key" What should I do in order to revert my aspx page to a previous version ?

How to avoiet null value in parameter

I want to send dat from my vb.net project by store procudure but if I take a three paramater in store procudure and and and I send two parmeter value than it does not work. How can I do it without error

Update Parameter doesn't update if Null


I have a vb.net page that has an optional parameter.   If a user enters data for that field, and clicks save, it saves fine via the stored procedure.  HOWEVER, if the user changes their mind, and wants to erase the data they entered, they go to the text field, and delete the characters, and click save, but no matter what, the stored procedure will not save the fact that they erased the data (it won't set it back to NULL).  If the user enters a space, the stored procedure will save the space, and if they enter different data, it will save the other data.  I can't figure out how to get it back to letting them set it to Null?      I think this is because it's an optional parameter, and the stored proc is used by several forms (Some of those forms do not include this parameter), but this form utilizes that optional paramater. 

Here's my stored procedure...

CREATE PROCEDURE [dbo].[123456]
@hdnMatterID int,
@BillingArrangementID int,
@BillingArrangementDetails varchar(200) = NULL,   -----This is the parameter that can't seem to get set back to null if a user changes their mind and tries to erase the stored data...
@BillingFrequencyID int


UPDATE  t123456
SET BillingArrangementID = @BillingArrang

WorkFlow Event Reveiver parameter "properties.ActivationProperties" is null.

I have been trying to write the event receiver on completion of my out of box "Approval - Sharepoint 2010 workflow" set on a Site Page library. I need to update some column on completion of the workflow.

So for this I need is the list and listItem to which the workflow is attached and the column that I need to update. I understand I can get this using "properties.ActivationProperties" but what I get is null value for this. Can someone help me in this regard? I also tried reading the same in workflowStarted event but even there I get the value as null.

SQL CE 3.5 Null Parameter Check



I cannot find a definitive answer for a very simple question. In SQL CE 3.5, I am attempting to execute the following:

            using (var connection = new SqlConnection(""))

                using (var command = connection.CreateCommand())

                    command.CommandType = CommandType.Text;
                    command.CommandText = "Select * From County Where CountyId = Coalesce(@Id,3)";
                    var dbParameter = command.CreateParameter();
                    dbParameter.ParameterName = "@

VS2010 RTM bug?? Error Occurred in deployment step 'Add Solution': Value cannot be null. Parameter


I'm getting this error with Visual Studio 2010 (RTM) deploying to SharePoint 2010 (also RTM).

An "Empty SharePoint Solution" project with an OOB "Module" item added. Try to deploy and I get:

Error Occurred in deployment step 'Add Solution': Value cannot be null. Parameter name: s

The account I'm developing with has:

  • Domain Admin
  • Local Admin
  • SharePoint Farm Admin
  • Site Collection Admin
  • SQL "sysadmin"
  • SQL "DBOwner" on all config / content databases
  • UAC is disabled

The WSP package is created successfully, and if I roll it out using STSADM then it works perfectly. For some reason though Visual Studio 2010 thinks that it cannot be deployed!

Any ideas??

Martin Hatch
MCPD .Net Web Development
MCTS WSS 3.0 | MOSS 2007
Visit my Blog - www.martinhatch.com

OLEDB source task + NULL Parameter



we are using SSIS 2005 and Sql server 2005. My stored proc has 3 parameter. 2 date parameters and 1 varchar parameter. The varchar parameter is set to null as default like this:

Alter procedure uspSPName







Error Value cannot be null Parameter name: type after move app to server


Hey, i have a WebSite project which i published, in the machine where i published the WebSite everything works smooth.

when i moving it to the server, i got the Error:

Value cannot be null.<br>Parameter name: type

Value cannot be null.
Parameter name: type

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.ArgumentNullException: Value cannot be null.
Parameter name: type


and the details of it:


[ArgumentNullException: Value cannot be null. Parameter name: type] System.Activator.CreateInstance(Type type, Boolean nonPublic) +2843963 System.Web.Profile.ProfileBase.CreateMyInstance(String username, Boolean isAuthenticated) +76 System.Web.Profile.ProfileBase.Create(String username, Boolean isAuthenticated) +312 System.Web.HttpContext.get_Profile() +108 PasswordRecovery.get_Profile() +39 PasswordRecovery.Page_PreInit(O

dynamic query with a null parameter to dont take in cosideration if null


Hi guys,

Do you know in a dynamic query how can I manage if a parameter isnull or not.

declare @businessunitidname varchar(15)
set @businessunitidname = NULL;
--print @businessunitidname

declare @eu_reporthubname varchar(15);
set @eu_reporthubname = Null;
declare @ownerid varchar(15);
set @ownerid = Null;

declare @SQL varchar(4000);

SET @SQL = ';with cte as
	select ''eu_mondayamid'' as WeekName,0 as WeekVal union all
	select ''eu_mondaypmid'',0 union all
	select ''eu_tuesdayamid'',1 union all

Value cannot be null. Parameter name: username - ASP.NET Profile



I'm having this very annoying issue.

Trying to make ASP.NET profile work in my MVC2 application.

This is the C# code:

using System.Web.Profile;

namespace MyProject.Lib.UserProfile
    public class UserProfile : ProfileBase
        public string FirstName { get; set; }

        public string LastName { get; set; }

        public string Town { get; set; }

        public string Address { get; set; }

        public string PostalCode { get; set; }

        public string Telephone { get; set; }

        public static UserProfile GetUserProfile(string username)
            return Create(username) as UserProfile;

        public static ProfileInfoCollection GetAllProfiles()
            return ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All);

Here is the web.config file:

    <profile enabled="true" 

how to set a optional parameter to NULL



I have got a problem about setting the optional parameter to NULL in sql sp. Initially I set all the parameters null in the sql sp. That's OK. But I would like to set the parameters to Null again if a particular parameter has a value of - 1 by using the "IF ELSE" statement block. However, the problem was that I was unable to set the parameter to NULL in the IF ELSE statement. So please correct my IF  ELSE statement in the store procedure. This is really urgent and important for my project. 

The store procudure is as follows:

ALTER PROCEDURE [dbo].[spGetMealsByNutritions] 
	@MealTypeID Int,
	@Gluten Bit = Null,
	@Dairy Bit = Null,
	@Egg Bit = Null,
	@Fish Bit = Null,
	@Veg Bit = Null,
	@Pork Bit = Null,
	@Beef Bit = Null,
	@Soy Bit = Null,
	@Sesame Bit = Null
	IF @Gluten < -1
	PRINT 'Success < this line is executed >
	PRINT 'Success'
		SET @Gluten = null <this line is never executed>
		PRINT 'Success'
	IF @Dairy < 0
		SET @Dairy = NULL
	IF @Egg < 0
		SET @Egg = NULL
	IF @Fish < 0
		SET @Fish= NULL
	IF @Veg < 0
		SET @Veg = NULL
	IF @Pork < 0
		SET  @Pork = NULL
	IF @Beef < 0
		SET @Beef = NULL

Add a global parameter to your ado.net entity data model which can be used to validate a session var


is there a way to add a global parameter to your ado.net entity data model which can be used to validate a session variable ? in that way you could have a general rule to get for instance only the records belonging to a specific user's profile logged in, is that possible?

In case that it were possible doing that way you will be making the rule valid for all entities in your model at once. right? 

Value cannot be null. Parameter name: Original_foo



I am trying to use the datadesigner for a project I normally have written the datalayer by hand seems to me you have much more control over whats going on , however , I am starting a project which is going to have the datalayer done in the data designer , but I cannot get past the most basic of tasks ...

I have a northwind database , I have simply dragged the table onto the datadesigner which creates the select , update statements etc , I then create an object data source and bind a gridview to the the dataadapter for the employees table

the gridview displays fine , showing all employees but when clicking edit and then update  I get the error

Value cannot be null.
Parameter name: Original_LastName

I simply dont know where to start with this ... any ideas ?

debug info below

[ArgumentNullException: Value cannot be null.
Parameter name: Original_LastName]
DAL.northwindTableAdapters.EmployeesTableAdapter.Update(String LastName, String FirstName, String Title, String TitleOfCourtesy, Nullable`1 BirthDate, Nullable`1 HireDate, String Address, String City, String Area, String PostalCode, String Country, String HomePhone, String Extension, Byte[] Photo, String Notes, Nullable`1 ReportsTo,

Compare a parameter with is null returns an error


When I try to execute a query that compares a parameter with is null, I get an error "The specified argument value for the function is not valid. [ Argument # = 1,Name of function(if known) = isnull ]"

This occurs with SQL Server CE 3.5 SP2 for Windows Mobile. With SQL Server CE 3.5 without SP1 or SP2 this error doesn't accurs.

Artur Almeida

dim connection As SqlCeConnection
  dim sqlcmd As SqlCeCommand
    connection = New SqlCeConnection("Data Source=\Storage Card\MyDatabase.sdf")
    Dim strSql As String = "Select * from MyTable where (@MyParam is null or MyField= @MyParam ")
    Dim param As New SqlCeParameter("@MyParam", DbType.DateTime)
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