.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

No definition for parameter error

Posted By:      Posted Date: September 17, 2010    Points: 0   Category :ASP.Net
Hi. I have a code where it will store values from textbox to gridview temporarily without sending to database. Now i have created a button,trying to send the values in temporary gridview to database. Here's the cs code : protected void BtnSendToDatabase_Click(object sender, EventArgs e) { foreach (DataRow row in dt.Rows) { Console.WriteLine(row["name"].ToString()); } SqlCommand cmd = new SqlCommand(); cmd.CommandText = "INSERT INTO Table1 (Company_Name) VALUES (@compName)"; cmd.Parameters.AddWithValue("@compName", TxtName.Text); foreach (DataRow row in dt.Rows) { cmd.Parameter.AddWithValue("@compName", row["name"].ToString()); cmd.ExecuteNonQuery(); } cmd.Dispose(); conn.Close(); conn.Dispose(); } But i'm getting this error: CS1061: 'System.Data.SqlClient.SqlCommand' does not contain a definition for 'Parameter' and no extension method 'Parameter' accepting a first argument of type 'System.Data.SqlClient.SqlCommand' could be found (are you missing a using directive or an assembly reference?) Source error: cmd.Parameter.AddWithValue("@compName", row["name"].ToString()); I tried to use command instead of cmd,but it still gives error. Any ideas guys?

View Complete Post

More Related Resource Links

ssrs 2008 R2 - report parameter with no default set throws java script error

We have recently upgraded from SQL Server 2008 to SQL Server 2008 R2....I am experiencing a problem with my report parameters on my SSRS reports. It seems that my report parameters that I do not have a specified 'default' value throws a java script error when I try and run/render the report under R2.  As soon as I put a 'default' value on the report param, everything is fine.  However, that is not the behavior we need for our reports...the user needs to pick their selection. Can anyone shed some light on this, it seems to be an AJAX problem...I need to be able to have report parameters with a list of values, but no 'default' value on the parameter.

Cannot delete external data list column due "Parameter name: combinedEncoded" error

Hello!   I migrated a Sharepoint 2007 to a Sharepoint 2010 by dbattach method. And now I want to delete the BDC list columns, but I'm getting this exception: System.ArgumentException:   Parameter name: combinedEncoded    at Microsoft.SharePoint.BdcClientUtil.SplitStrings(String combinedEncoded) What should I do to delete properly this columns?   Many thanks!

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 ?

Error on INSERT INTO (using Parameter) within Execute SQL task



I'm sure there is a simple solution to this, however to save my banging my head against a brick wall: -

Within the "Execute SQL Task Editor" I have the following; -

Parameter Mapping Tab; -

Variable Name; - System::PackageName,
Directtion; - Input,
Data Type; - NVARCHAR,
Parameter Name; - 0,
Parameter Size; - 100

General Tab; -

SQLStatement; - INSERT INTO dbo.CustomSSISLog  (System::PackageName)     VALUES (?)

When I click on the "Parse Query" button I get the following error; - "

The query failed to parse. Parameter Information cannot be derived from SQL statements. Set parameter information before preparing command.


The table exists as follows; -

USE [ErrorLog]
CREATE TABLE [dbo].[CustomSSISLog](
	[CustomSSISLogKey] [int] IDENTITY(1,1) NOT NULL,
	[PackageName] [nvarchar](100) NULL

Any help would be greatly appreciated.

Kind Regards,


If you have found any of my posts helpful then please vote them as helpful. Kieran Wood MCTS BI, PGD SoftDev (Open), MBCS http://uk.linkedin.com/in/bileeds

Parameter error in the web based application


Hello Everyone,

I am working on a web based application wherein I have a created 2 dropdown lists for the user to select. If the user does not select any value from any or both of the dropdown lists, they should see a message- 'Please a select a value for trade code' or 'Please a select a value for direction'. Instead I am getting this development error:

'Procedure or function 'usp_AdminPageCustomerGroupingSearch' expects parameter '@tradecode', which was not supplied.'

As I am still novice to asp.net or C#, I am unable to find the correct code to catch this error and display the relevant message to the user. Could someone please help me with this ? The following is the slice of the C# code which is related to the dropdown list:



 void populateGV()DataView dv = new DataView();<

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

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

Error 2 Type or namespace definition, or end-of-file expected


Hi frnds,

I am new to this programming.. I am trying to download files from a specific folder in ftp server. after downloading those files i want to store in my computer. . I got the code on internet but wen i am trying i am getting this error Error 2 Type or namespace definition, or end-of-file expected. .  please help me very urgent. here is my complete code


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Net;
using System.Text;
using System.Runtime.InteropServices;

public partial class _Default : System.Web.UI.Page 
    protected void Page_Load(object sender, EventArgs e)
        string[] files = GetFileList();
        foreach (string file in files)

        public string[] GetFileList()
            string[] downloadFiles;
            StringBuilder result = new StringBuilder();
            WebResponse response = null;
            StreamReader reader = null;
                FtpWebRequest reqFTP;
                reqFTP = (FtpWebReq

SSRS 2005 Error: Cannot add multi valued query parameter for data set because it is not supported b



getting the above error when running a report in SSRS 2005, using a stored procedure with many input parameters,

connected to a Sybase IQ database,

I want to have some of the prompts to be multi valued prompts.......

Please advise on how to fix......



Syntax error adding a parameter to xp_cmdshell command



I am trying to add a parameter to a bcp query that will be run in xp_cmdshell but am getting a syntax error at the '+' character.  Been staring at it for two hours and have concluded that  some outside help is needed. 

The command is:

EXEC xp_cmdshell 'bcp "SELECT * FROM [CensusData].[dbo].[Main] where zBarCode = ' + @zBarCode + '"  queryout "C:\temp_housing_data.txt" -T -c -t -S "MyServerName"'

The syntax is on the first '+' character and it simply says "Incorrect syntax near '+'"

Please help.

An error occurred while executing the command definition. See the inner exception for details.



In my mvc asp.net application, I am getting error in edit function : in given code

public ActionResult Edit(int id)

var res = (from r in objeEntities.DocumentationsSet.Include("DocStatus")
where r.textid == id select r)

I am getting this exception:

  • Source : System.Data.Entity

    Stack Trace : at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Ex

passing parameter creates error


I am stuck,  I created a gridview and sqldatasource with a parameter and then go this error

 Exception Details: System.Data.SqlClient.SqlException: Must declare the table variable "@SQLTable".

<asp:GridView ID="GridView1" runat="server" DataSourceID="SQLTableData">
        <asp:SqlDataSource ID="SQLTableData" runat="server" 
            ConnectionString="<%$ ConnectionStrings:PhilConnectionString %>" 
            SelectCommand="select * from @SQLTable">
                <asp:SessionParameter Name="SQLTable" type="String" SessionField="SQLTableName" />



Parameter error writing to excell 2007 file using SQL 2008 Server Agent JOB, works in BIDS.


I am getting the following error message when I try to run a script that writes to an excel file calling my Package with a SQL 2008 JOB.

Executed as user: xxxx\xxxxxxx. Microsoft (R) SQL Server Execute Package Utility  Version 10.0.1600.22 for 32-bit  Copyright (C) Microsoft Corp 1984-2005. All rights reserved.    Option "12.0;HDR=YES;" is not valid.  The command line parameters are invalid.  The step failed.

This same package runs correctly if I execute it in dev mode in BIDS.  I had to set 64bitmode to false in Dev mode to get it to work.  I set executable options in the job step to 'run in 32 bit mode'  The error message indicates to me it is trying to run in 32 bit mode which should be correct but it doesn't like the extended parameters. .   

Here is my connection string from the data sources tab on the job

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\xxxx.xlsx;Extended Properties="EXCEL 12.0;HDR=YES";

This was filled in ny the connection object for me.  I have read the article closely at http://toddmcdermid.blogspot.com/2009/10/quick-reference-ssis-in-32-and-64-bits.html and still can't figure out what I need to change. 

Error: does not contain a definition



    I encounter one error message but fail to solve it.

    The error message is: CS1061: 'System.Collections.Generic.IEnumerable<AssistantSystem.ViewModels.UserViewModel>' does not contain a definition for 'numberOfUsers' and no extension method 'numberOfUsers' accepting a first argument of type 'System.Collections.Generic.IEnumerable<AssistantSystem.ViewModels.UserViewModel>' could be found (are you missing a using directive or an assembly reference?)

I have defined the numberOfUsers in the UserViewModel and it is used to pass the value to the view by the UserController.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AssistantSystem.ViewModels
    public class UserViewModel
        public int numberOfUsers { get; set; }
        public List<userMaster> users { get; set; }


Also, I debug it and find that the numberOfUsers contains a value in the controllers.

How can I solve this problem?

It also fails to show the user list.


<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.M

database parameter specified with the configdb command is invalid error


Im using:

Windows server 2008 32 bit. SQL Server 2008 Enterprise. Sharepoint server 2007 Sp2.

I am trying to runthe fllowing command but getting the error that follows:

Psconfig -cmd configdb create -server "sername" database DBName user Domain\user password pswd admincontentdatabase SharePoint_AdminContent

The database parameter specified with the configdb command is invalid.
The database name located at the specified database server has an incorrect coll
ation.  Rebuild the database with the Latin1_General_CI_AS_KS_WS collation or cr
eate a new database using the Latin1_General_CI_AS_KS_WS collation.

Can anyone tell me how to sort this out?


Cannot Import application Definition to Business Data Catalog (BDC) -- Error: Access Denied

I want to import an application definition to my Business Data Catalog (BDC).

I log into my Shared Service and select Import application definition.

I am redirected to page that says Error: Access Denied

My account is:

1. An Administrator on the windows server running sharepoint
2  A member of the Farm Administrators
3. Added individually with Full Control to Central Administation
4. Added individually with Full Control to my shared service.

John Bailo

Classes and Namespaces - Error CS0101 the namespace already contains a definition for


I keep getting the error: Error message: CS0101: The namespace '<global namespace>' already contains a definition for 'checkvalue'.

Then, I rename the Inherits from the @page directive in both the .aspx and .aspx.cs pages and it works!

My website has only 2 pages, and both use the same class (same class name, exactly same syntax) but it has been copied and pasted and the 2 aspx pages (and aspx.cs pages) are not referencing each other.

In other words, both aspx.cs pages (called page1.aspx.cs and page2.aspx.cs) has the class

public class CheckValue
        return true;

Both the aspx pages reference the 'inherits' files seperately:

<%@ Page Language="C#" CodeFile="page1.aspx.cs" Inherits="_1" %>

and my code behind

public partial class _1 : System.Web.UI.Page

and for my second page

<%@ Page Language="C#" CodeFile="page2.aspx.cs" Inherits="_2" %>

and my code behind

public partial class _2 : System.Web.UI.Page

I don't use the .resx file.

Why does this error happen some times, and not other times?


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