Select Parameter Not Working On SqlDataSource.

Jul 1, 2010

I am using the stored procedure below for the select command of a SqlDataSource, and I'm trying to pass a query string parameter, but I get this error:

Procedure or function 'ActivationCampaignGetById' expects parameter '@campaignId', which was not supplied.

The parameter is present in the query string:

http://localhost:62681/Activations/ActivationCampaignDetails.aspx?id=98

Here is my DataSource code:

<asp:SqlDataSource ID="campaignDataSource" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:ProVantageMediaManagement %>"
SelectCommand="ActivationCampaignGetById" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="98" Name="campaignId"
QueryStringField="id" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>

And my stored procedure declaration:

ALTER procedure [dbo].[ActivationCampaignGetById]
@campaignId int
as
select

View 8 Replies


Similar Messages:

Select Parameter Not Working On SqlDataSource?

Apr 18, 2010

I am using the stored procedure below for the select command of a SqlDataSource, and I'm trying to pass a query string parameter, but I get this error:

Procedure or function 'ActivationCampaignGetById' expects parameter '@campaignId', which was not supplied.

The parameter is present in the query string:

http://localhost:62681/Activations/ActivationCampaignDetails.aspx?id=98

Here is my DataSource code:

<asp:SqlDataSource ID="campaignDataSource" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:ProVantageMediaManagement %>"
SelectCommand="ActivationCampaignGetById" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="98" Name="campaignId"
QueryStringField="id" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>

And my stored procedure declaration:

ALTER procedure [dbo].[ActivationCampaignGetById]
@campaignId int
as
select

View 1 Replies

Passing Textbox In Gridview Header Template As A Parameter In A Sqldatasource Select

Nov 4, 2010

I have a gridview that displays the contents of a database table, using an sqlDataSource. That part (including inserting, updating and deleting rows) works perfectly. What I am wanting to do is add a "search" function to restrict the rows returned to a user entered name. I have a textbox for the name to be searched and a "Search" button in the headertemplate as such:

[Code]....

The DataBind fails, with the error:

Could not find control 'txtSearchName' in ControlParameter 'username'.

View 1 Replies

DataSource Controls :: Output Parameter Not Working To Sqldatasource?

Aug 10, 2010

I am trying to get the uniqueidentifier value from a insert SP and retreive that using a sqldatasource and pass that value to store files in the relevent folder.

the SQL stored procedure

ALTER PROCEDURE [dbo].[sp_InsertIPRT]
@Site nchar(10),
@Description nvarchar(MAX),
@Application nvarchar(MAX),
@Coordinator nchar(50),
@ProjectNumber nchar(50),
@Manager nchar(50),
@DateRequested date,
@DateRequired date,
@Issues nvarchar(MAX),........

View 2 Replies

ADO.NET :: Add A Parameter To Sqldatasource During RowDataBound?

Aug 12, 2010

So I have a gridview within a gridview (I have a one to many table) my first gridview is working well, but my second gridview has a sqldatasource that has a select parameter(the default value was just for testing)

<asp:SqlDataSource ID="dsCountryByTripID" runat="server" ConnectionString="<%&#36; ConnectionStrings:bahDatabase %>" SelectCommand="spSelectCitiesByTripID" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:Parameter Type="Int32" Name="tripID" DefaultValue="56" /> </SelectParameters> </asp:SqlDataSource>

during my Gridview1 row databound I am trying to grab the columns that match the tripID. But dsCountryByTripID which is my datasource, is only going inputted with the last tripID.

protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e) { GridView gv2 = (GridView)e.Row.FindControl("GridView2"); if (e.Row.RowType == DataControlRowType.DataRow) { dsCountryByTripID.SelectParameters.Clear(); DataRowView drv = (DataRowView)e.Row.DataItem; string tripID = (drv["pkiTripId"]).ToString(); dsCountryByTripID.SelectParameters.Add("tripID", DbType.Int32, tripID); //gv2.DataBind(); //e.Row.DataBind(); } }

View 1 Replies

C# - Add A Parameter To Sqldatasource During RowDataBound

Aug 11, 2010

So I have a gridview within a gridview (I have a one to many table) my first gridview is working well, but my second gridview has a sqldatasource that has a select parameter(the default value was just for testing)

<asp:SqlDataSource ID="dsCountryByTripID" runat="server"
ConnectionString="<%$ ConnectionStrings:bahDatabase %>"
SelectCommand="spSelectCitiesByTripID" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter Type="Int32" Name="tripID" DefaultValue="56" />
</SelectParameters>
</asp:SqlDataSource>
during my Gridview1 row databound I am trying to grab the columns that match the tripID. But dsCountryByTripID which is my datasource, is only going inputted with the last tripID.
protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
{
GridView gv2 = (GridView)e.Row.FindControl("GridView2");
if (e.Row.RowType == DataControlRowType.DataRow)
{
dsCountryByTripID.SelectParameters.Clear();
DataRowView drv = (DataRowView)e.Row.DataItem;
string tripID = (drv["pkiTripId"]).ToString();
dsCountryByTripID.SelectParameters.Add("tripID", DbType.Int32, tripID);
//gv2.DataBind();
//e.Row.DataBind();
}
}

View 2 Replies

Use A Custom Parameter With SqlDataSource?

Jan 17, 2011

I want to add a GridView control to one of my views that is backed by a SqlDataSource. The SelectCommand query is parametrized on the aspnet_Users.UserId GUID for the currently-logged-in user, so I need a way to pass the user ID as a parameter.

I read How to utilize ASP.NET current user name in SqlParameter without code-behind and decided to create a custom Parameter named UserIdParameter:

namespace MyApp.Web
{
public class UserIdParameter : Parameter
{
public UserIdParameter(string name)
: base(name)
{
}
protected UserIdParameter(UserIdParameter parameter)
: base(parameter)
{
}

protected override Parameter Clone()
{
return new UserIdParameter(this);
}
protected override object Evaluate(HttpContext context, Control control)
{
return Membership.GetUser().ProviderUserKey;
}
}
}

In the ASPX view I then added:

<%@ Register TagPrefix="my" Namespace="MyApp.Web" %>

in a line after the <%@ Page ... %> line as well as:

<SelectParameters>
<my:UserIdParameter Name="UserId" />
</SelectParameters>

within the asp:SqlDataSource element.

Unfortunately I get a Parser Error ("An error occurred during the parsing of a resource required to service this request. review the following specific parse error details and modify your source file appropriately.") with the following highlighted in red:

<my:UserIdParameter Name="UserId" />

Visual Web Developer 2010 Express is also informing me that "Element 'UserIdParameter' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing."

Do I need to modify Web.config in some way? If not, what do I need to do to be able to use my custom UserIdParameter parameter?

View 2 Replies

SQL Reporting :: MDX Query Parameter From SSRS / Setup @from And @to As Parameter But Not Working?

Aug 21, 2010

I've a MDX Query that has where clause as shown below.I'm designing report using SSRS 2008. How can i pass date as parameter? I tried to setup @from and @to as parameter but not working?

WHERE ( {[Date Central].[Calendar Date].[2010-04-01 00:00:00]:[Date Central].[Calendar Date].[2010-08-30 00:00:00]} )

need it to work as
WHERE ( {[Date Central].[Calendar Date].[@From]:[Date Central].[Calendar Date].[@To]} )

View 1 Replies

C# - How To Pass Parameter To SQlDataSource From Gridview

Apr 7, 2010

Gridview has many columns and a Delete button as well. Delete button is a control as TemplateField

[code]....

Now associated SQLDataSource's Delete command's stored procedure is expecting two parameters. One is going from DataKeyNames (RowID), other one i wanna pass is the Text of btnDelete (True or False).

View 1 Replies

C# - Pass String Parameter To SqlDataSource?

Sep 16, 2010

i have placed a SqlDataSource component on my aspx page but while configuring the SqlDataSource in the "Test Query" Step I am passing the following parameters :But when i click ok it returns following error:This error occurs when i pass the string :

INFO, WARN, ERROR,

I have tried a lot of combinations but nothing works. It works only if i pass one of the three words in single quotes like this :'ERROR'Infact the INFO WARN and ERROR are the various levels available in the table. Each record can have only one level and in the sql query i am using IN("-----") to match the criteria, hope you understand.

View 2 Replies

How To Specify Parameter Value For Stored Procedure In SqlDataSource

Mar 16, 2011

Being new to using the declarative syntax of SqlDataSource I am trying to figure out a way to set the value of a parameter to a stored procedure. I have a Client_ID that is passed via the Request Object and I need to set the Client_ID before the stored procedure of the SqlDataSource is executed.

Does the stored procedure parameter have to be predefined in the ASPX markup or can it be added dynamically in the code-behind? Would anyone have an example that demonstrates the SqlDataSource markup with a stored procedure and parameter as well as setting that parameter value in code-behind?

View 1 Replies

C# - Updating SqlDataSource Parameter Via LinkButton?

Apr 10, 2010

I'll try to explain what I'm doing the best I can, but I'm pretty new to asp.net so be patient with me. I have a SqlDataSource which returns a simple select statement based on the WHERE clause using @COURSE_ID

What I want to-do is every time any one of 2 (this will change as it's going to be generated) asp:LinkButtons are pressed, they will change the @COURSEID value which i'd like to associate with the specific button.

Buttons:

<asp:LinkButton ID="LinkButton2" runat="server" onclick="MenuUpdate_Click">Course1</asp:LinkButton>
<asp:LinkButton ID="LinkButton1" runat="server" onclick="MenuUpdate_Click">Course2</asp:LinkButton>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:connString %>" SelectCommand="SELECT Chapter.chapterName, Chapter.chapterID
FROM Chapter
WHERE Chapter.courseID = @COURSE_ID
">
C#
protected void MenuUpdate_Click(object sender, EventArgs e)
{
Parameter p = SqlDataSource1.SelectParameters["COURSE_ID"];
SqlDataSource1.SelectParameters.Remove(p);
SqlDataSource1.SelectParameters.Add("COURSE_ID", THIS NEEDS TO BE VALUE ASSOCIATED TO BUTTON);
ListView1.DataBind();
UpdatePanel1.Update();
}

If anyone has any suggestions that'd be great, I've been trying lots of different things all night with no success :(

View 1 Replies

C# - Use User.Identity.Name As A Parameter For SqlDataSource?

Oct 5, 2010

For SqlDataSource I can configure the external source for the incoming paramater. For example it might be a QueryString, Session, Profile and so on. However I do not have an option to use User as a source.

I know that I could provide value for the parameter in Inserting,Selecting,Updating,Deleting events. But I do not think that this is an ellegant solution because I have some parameteres already definied in aspx file. I do not want to have parameters defined in two separate places. It makes mess.

So can I somehow define this parameter in .aspx file?

<SelectParameters>
<asp:QueryStringParameter DefaultValue="-1" Name="ID"
QueryStringField="ID" />
//User.Identity.Name goes here as a value for another parameter
</SelectParameters>

View 1 Replies

SQL Server :: Add Parameter To SqlDatasource With Update In GridView?

Jul 25, 2010

I have GridView1 and SqlDataSource1. I use EnableEditing to GridView1. This is Code of GridView

<
asp:GridView
ID="GridView1"
Width="100%"
runat="server"
AutoGenerateColumns="False"
BackColor="White"
BorderColor="#3366CC"
BorderStyle="None"
BorderWidth="1px"
CellPadding="4"
DataKeyNames="DoctorID"
DataSourceID="SqlDataSource1">
<RowStyle
BackColor="White"
ForeColor="#003399"
/>
<Columns>
<asp:BoundField
DataField="DoctorID"
HeaderText="DoctorID"
InsertVisible="False"
ReadOnly="True"
SortExpression="DoctorID"
/>
<asp:BoundField
DataField="DoctorName"
HeaderText="DoctorName"
SortExpression="DoctorName"
/>
<asp:BoundField
DataField="City"
HeaderText="City"
SortExpression="City"
/>
<asp:BoundField
DataField="Str"
HeaderText="Str"
SortExpression="Str"
/>
<asp:BoundField
DataField="StrRegion"
HeaderText="StrRegion"
SortExpression="StrRegion"
/>
<asp:BoundField
DataField="StringLevels"
HeaderText="StringLevels"
SortExpression="StringLevels"
/>
<asp:BoundField
DataField="Streat"
HeaderText="Streat"
SortExpression="Streat"
/>
<asp:BoundField
DataField="Email"
HeaderText="Email"
SortExpression="Email"
/>
<asp:BoundField
DataField="Mobile"
HeaderText="Mobile"
SortExpression="Mobile"
/>
<asp:BoundField
DataField="HomePhone"
HeaderText="HomePhone"
SortExpression="HomePhone"
/>
<asp:BoundField
DataField="ClinicPhone"
HeaderText="ClinicPhone"
SortExpression="ClinicPhone"
/>
<asp:BoundField
DataField="Fax"
HeaderText="Fax"
SortExpression="Fax"
/>
<asp:BoundField
DataField="address_details"
HeaderText="address_details"
SortExpression="address_details"
/>
<asp:BoundField
DataField="Expr1"
HeaderText="Expr1"
SortExpression="Expr1"
/>
<asp:BoundField
DataField="VisitPlaceStr"
HeaderText="VisitPlaceStr"
SortExpression="VisitPlaceStr"
/>
<asp:CommandField
ShowEditButton="True"
/>
</Columns>
<FooterStyle
BackColor="#99CCCC"
ForeColor="#003399"
/>............

View 1 Replies

Use JQuery Datepicker As A Control Parameter For SqlDataSource?

Mar 24, 2010

I have the need to display a date in this format: dd/mm/yyyy. This is actually being stored in an ASP.NET textbox and being used as a control parameter for a select on the GridView. When the query is run, though, the date format should change to 'd M y' (for Oracle). It is not working. Can someone tell me what I'm doing wrong? Right now I am pushing the "new" format to a invisible label and using the label as my control param:

$(document).ready(function() {
//datepicker for query, shown traditionally but holding an Oracle-needed format
$('[id$=txtBeginDate]').datepicker({ minDate: -7 , altFormat: 'd M y' });
//get alt format
var altFormat = $('[id$=txtBeginDate]').datepicker("option", "altFormat");
//set date to be altformat
$('[id$=lblActualDate]').datepicker("option", "altFormat", 'd M y');
});

View 2 Replies

DataSource Controls :: SqlDataSource - Parameter For IN() Clause

Apr 30, 2010

I have an SqlDataSource query that should use an input parameter for multiple integer values, like:

select * from table1 where TableID IN (1,2,3,4,5)

->

select * from table1 where TableID IN (@IDValues)

How do I do that ? Default parameter settings won't work, returning "invalid integer value" . I suppose that parameter should be passed as some kind of array that SQL recognizes as multiple integer values , but what's the correct way of setting this ?

View 4 Replies

DataSource Controls :: SqlDataSource Parameter Default Value?

Nov 5, 2010

I am using SqlDataSource control that retrieves information based on a city value from another control (textbox) on the page entered by the user.

[Code]....

The query works fine when the user enters a name of a city. However, if I leave the textbox blank and enter nothing, no records are returned by the query.I need all records to be returned when user leave the textbox blank and there is no value of the city.How to do that?is there a default value can do that?

View 4 Replies

Web Forms :: Pass Cookie Value As Parameter To SqlDataSource

Jan 24, 2016

asp:querystringparameter assign value how to ...

View 1 Replies

Getting The Parameter Values Being Passed To SQL Database Via SQLDataSource Control

Sep 1, 2010

I have a SQLDataSource control that is calling a database stored procedure, and passing quite a large number of paramaters, and the stored proc returns records that populates a gridview control. When I walk through the code behind to determine the values being passed, is there any way that I can see exactly how the parameters are being formated and passed to the stored proc?

View 2 Replies

Forms Data Controls :: Using AND / OR Parameter From A DropDownList In A SqlDataSource

Jan 29, 2010

I am facing a small issue in using a DropDownList that has only two values (AND and OR) which i want to use to configure a SQL Query in a SqlDataSource. How can i use this thing by passing the value in a SqlDataSource Select Query in such a way to Bind the Result to a GridView. I want something like this -

SELECT [somefields] FROM instinvoice WHERE Namen = @Namen @Option InvoiceNo = @invoiceno where @Namen is from a DropDownList and InvoiceNo is from a TextBox

I m having a problem in specifying this @Option parameter from a DropDownList which contains only two list items - AND and OR. On the Basis of the Selected Value from this DropDownList i want to execute query like

SELECT [somefields] FROM instinvoice WHERE Namen = @Namen AND InvoiceNo = @invoiceno

or

SELECT [somefields] FROM instinvoice WHERE Namen = @Namen OR InvoiceNo = @invoiceno

Using the Query with @Option gives me a Parsing Error. Why is that so. How can I implement this scenario.

View 3 Replies

DataSource Controls :: SqlDataSource Get Output Parameter And Assign To A Var

May 22, 2010

[Code]....

How do I get the "NewID" parameter value form the above datasource and assign it to a select parameter in a different sqldatasource?

View 2 Replies

DataSource Controls :: Set Null Value To SqlDataSource Insert Parameter?

Dec 21, 2010

this is my html code [Code]....

i need to set null value to SqlDataSource Insert Parameter at runtime

i am used this code

[Code]....

View 5 Replies

Data Controls :: SqlDataSource Populate Dropdownlist With Or Without Parameter?

Aug 14, 2013

I use SqlDataSource control to list out search result when user choose a date, but if the date is null, then it will list out all record. How to do the sql command?
 
SELECT Ref_No as name, Job_Order_ID as value
FROM Job_Order
WHERE (Status <> 'JO_Completed') AND (Delivery_Date = @jaDate)
OR (Status <> 'JO_Completed') ORDER BY Ref_No 

[Code].....

View 1 Replies

How To Dynamically Add Update Parameter Value To Sqldatasource In GridView From RowCommand Event

Feb 4, 2010

I have two image buttons in a gridview, one to approve the opening of the record and one to approve the closing of the record. I have added a CommandName to each button (OpenApproved and CloseApproved) and in the grids rowcommand I would like to update the database with the Username of the person clicking the button, Username goes into either the OpenLeadApprover or CloseLeadApprover field depending on which button is pressed. The grid has a sqldatasource with an Update stored procedure which has three parameters, @WorkOrderIDWhat I have tried to do in the RoeCommand event is declare a variable for the sqldatasource and add the parameter value to it, then run the update command. Here is the code:

[Code]....

View 4 Replies

DataSource Controls :: Querystring Or Control Parameter In Sqldatasource Binding

Jan 21, 2010

after I pass querystring parameter to page,page works as expected,but after that when I change my control parameter(dropdownlist selected value how can I set querystring to null or empty...

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved