Forms Data Controls :: Stored Procedure - Parameters Required?

Oct 13, 2010

The update option is using a stored procedure. There are no parameters fro the SP but the error message is saying that parameters are expected. If executed as SQL string then it works OK. I need to use a SP as other updates are required. Code: THIS WORKS

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:appConnectionString%>"
ProviderName = "<%$ ConnectionStrings:appConnectionString.ProviderName %>"
SelectCommand = "SELECT * FROM [qryNewManifestSub] where manifestid = 6855"
InsertCommand = "INSERT INTO [qryNewManifest] ([LocationId], [ManifestDate],
[RouteId], [VehicleType], [ManifestType])
VALUES (@LocationId,
CONVERT(DATETIME,@ManifestDate,103), @RouteId, @VehicleType, @ManifestType)"
UpdateCommand = "INSERT INTO dbo.tbl_DEBUG
(ManifestId, ManifestTripId, LocationId, Manifestdate, RouteId, VehicleType, ManifestType)
VALUES (1,2,3,'01/01/2010',4,5,6)"
UpdateCommandType="Text"
DeleteCommandType="Text">
<InsertParameters>
<asp:Parameter Name="LocationId" Type="Int32" />
<asp:Parameter Name="ManifestDate" Type="DateTime" />
<asp:Parameter Name="RouteId" Type="String" />
<asp:Parameter Name="VehicleType" Type="String" />
<asp:Parameter Name="ManifestType" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource

This does not work Error Message - parameters expected but none given

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:appConnectionString%>"
ProviderName = "<%$ ConnectionStrings:appConnectionString.ProviderName %>"
SelectCommand = "SELECT * FROM [qryNewManifestSub] where manifestid = 6855"
InsertCommand = "INSERT INTO [qryNewManifest] ([LocationId], [ManifestDate],
[RouteId], [VehicleType], [ManifestType])
VALUES (@LocationId,
CONVERT(DATETIME,@ManifestDate,103), @RouteId, @VehicleType, @ManifestType)"
UpdateCommand = "usp_TESTSP"
UpdateCommandType="StoredProcedure"
DeleteCommandType="Text">
<InsertParameters>
<asp:Parameter Name="LocationId" Type="Int32" />
<asp:Parameter Name="ManifestDate" Type="DateTime" />
<asp:Parameter Name="RouteId" Type="String" />
<asp:Parameter Name="VehicleType" Type="String" />
<asp:Parameter Name="ManifestType" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>
Stored Proc
usp_TESTSP

This SP has been tested and works OK

USE [TMSWEBALL]
GO
/****** Object: StoredProcedure [dbo].[usp_TESTSP] Script Date: 10/06/2010 14:03:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[usp_TESTSP]
As
BEGIN
SET NOCOUNT ON added to prevent extra result sets from
interfering with SELECT statements.
SET NOCOUNT ON;
*/
INSERT INTO dbo.tbl_DEBUG
(ManifestId, ManifestTripId, LocationId, Manifestdate, RouteId, VehicleType, ManifestType)
VALUES (1,2,3,'01/01/2010',4,5,6)
END
>

View 1 Replies


Similar Messages:

Forms Data Controls :: Load A DropDownList Into A GridView With A Select Stored Procedure With Parameters

Sep 19, 2010

I want to have a dropdownlist in the footer row of a gridview. The dropdownlist must be populated with an stored procedure that receives a parameter and has a select. Is that posible?? I think yes but I having problems with the parameters.

[Code]....

The exception says incorrect sintax... but I've changed the procedure for something very simple to solve the problem like select 'hello' or select 1, 'hello' and I'm getting the same problem...

View 3 Replies

Forms Data Controls :: Passing Parameters To Stored Procedure When Edit Button Is Clicked In GridView

Oct 27, 2010

I have a grid view that populates and displays data at btn click event from the following sql statement in one of the SP:

SELECT

reg_code, pc_serial, act_code
FROM user_reg
WHERE reg_code=@reg_code

I want to pass parameters to the other Stored procedure when the edit button is clicked in order to update the 2 columns in the specific row at the time. I now how to pass parameters in a regular btn click event or function, but in the case of edit btn in grid view I don't know how to capture data from specific row and then pass it to the SP. Here is Stored Procedure to update the columns (every user always has the same reg code, but may have more than one serial number and activation code, I want to let the user update serial number and then based on the serial number generate new activation code in the SP.):

[Code]....

View 3 Replies

DataSource Controls :: Validating Length Of Data In Context With Stored Procedure Parameters?

Apr 19, 2010

I am building a WCF Web Service that has a Business Logic layer (that implements all validation logic and other business rules) and a Data Access Layer that makes calls to Stored Procedures in my database.

I would like to be able to validate the length of data passed against that of the length of the parameters in the Stored Procedures without having to explicitly define the parameter lengths in my WCF Web Service.

Eg:

Person Object
Person.Name = "John Dhoe"
Person.Age = 37
SQL Stored Procedure
SavePerson
FullName Varchar(15)
Age Int

In my BLL or DAL, I would like to be able to do something like :

If(Person.Name.length == SavePerson.Parameters["FullName"].Length)
{
Return true;
}
else
{
Return false;
}

Has anyone tried this out before? Is this even possible?

View 2 Replies

ADO.NET :: Stored Proc With Output Parameters / Data In The Output Parameters From The Stored Procedure?

Mar 30, 2011

I have a stored procedure that works fine for classic asp, but how can I get my output parameters data back from in /MVC 2 / linq/ entities framework model . I have inported the function also, but when i try to code it i dont get results ...i know this is a matter of lack of / knowledge or exmple because i have been scouring the web for it and cannnot find into that accually works.

here is the stored proc.

[Code]....

Here was the one of the few tries I did:

[Code]....

but it executes fine does not give me an error, but also does not return the info i need to the viewmodel

I keep seeing stuff about "ref" on the net but "ref" shows " arbument # should not be passed with the ref keyword.

So i am not sure if there is a problem with the model, or with my understanding this, Now for your info I can do the same step with returning a dataset from a stored procedure fine, but I dont want a data set I just want excatly the data in the output parameters from the stored procedure.

View 2 Replies

DataSource Controls :: Function To Accept Unlimited Parameters For Stored Procedure - Determine Data Type

Jun 22, 2010

I am trying to write a function that can be called to run a stored procedure. I pass the stored procedure name, followed by as many parameters as I need to run the procedure. I am able to do this by using the params keyword, so my function looks something like this;

[Code]....

How can I determine what the data type of the parameter is? Maybe I need to alter the string[] part, above?

View 5 Replies

DataSource Controls :: How To Pass Parameters To Stored Procedure

Apr 30, 2010

Ive tried a few ways of doing this without success and got together a simplified example so hopefully I can get an answer. When I try to INSERT using a stored procedure InsertTest (normal SQL works OK) I cannot. I need to know how to pass the @Model parameter to the Stored procedure

Have a Stored procedure which can be executed and after entering string for @Model through wizard a new record is created

My asp:SqlDataSource includes InsertCommand="InsertTest" InsertCommandType="StoredProcedure"
Also my <InsertParameters includes the asp:Parameter Name="Model" Type="String"/>

My drop down (and I think this is where the problem is ). Record is Inserted after choosing Model and pressing enter

Do I have to set one of the properties in the drop down to tell the Stored procedure the parameter being passed is the parameter Model ??

[Code]....

View 4 Replies

DataSource Controls :: Trying To Populate A Dropdown From A Stored Procedure That Includes Parameters

Nov 11, 2010

I am trying to populate a dropdown from a stored procedure that includes parameters. The parameters are programmatically defined variables. I have been working at this for hours, and scoured the internet for a tutorial. I have come up with the following solution below. However, it does not work. Its not pulling any data, and I am not even sure that the page is making it into the GetLast5Schedules_Selecting Event. There has to be a more efficient/less time consuming way to do this!

[Code]....

[Code]....

[Code]....

View 1 Replies

DataSource Controls :: Grab Unknown Parameters From Stored Procedure From Code Behind?

May 3, 2010

I am trying to allow users to grab their stored procs and call certain ones from within code. I can get the stored procedures and then fill a dropdown with them, but what I cannot find at this point is how to get the parameters that each stored procedure needs. I would like, once an SP is chosen from the dropdown to make a call to the db with that sp name and grab its paramter list so I can report what needs to be sent in to the user.

View 1 Replies

DataSource Controls :: Pass The ID And SelectedDate Values In To The Stored Procedure As Parameters?

Jun 14, 2010

How do I pass the ID and SelectedDate values in to the stored procedure as parameters??

[Code]....

View 2 Replies

DataSource Controls :: Blank GridView With Stored Procedure And Form For Parameters?

Jun 11, 2010

[Code]....

View 2 Replies

Web Forms :: Passing Stored Procedure Parameters Dynamically Through ArrayList Values

Mar 8, 2012

I want to passed stored procedure parameters from crystal report to pass those parameter dynamically by arraylist because user will pass parameters by using data driven web pages (can be different reports with different parameter). how can i pass through parameter array lists to crystal report setreportparameters fields.

My code;

public void ConfigureReports(ArrayList valuesLists,ArrayList parameterLists)  {  
rptReportViewer.RefreshReport();  
DataBaseHelper.myReportConnectionInfo = new ConnectionInfo();
DataBaseHelper.defineConnection = null; 

[Code] ...

View 1 Replies

Forms Data Controls :: Working Procedure With Varbinary From Existing Stored Procedure?

Feb 22, 2010

[Code]....

i have a stored procedure with this values and i need just to make a button that will send something to "Equip" column,how to do it? write the values on my webpage and make a button to exec the procedu

View 1 Replies

Forms Data Controls :: Populate Drop Down List Using Stored Stored Procedure

Mar 14, 2010

i want data to drop down list using stored procedure .

However im not able to do that.

View 3 Replies

C# - Getting 'too Many Parameters Passed' To Stored Procedure?

Nov 30, 2010

I'm having trouble figuring this error out. I have a grid on an ASPX page that displays data from a stored procedure in an SQL Server 2008 database. When the page loads, I get the following error:

"Procedure or function <sp_name> has too many arguments specified."

Here is the code for the grid and the datasource:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" ShowFooter="True" OnRowDataBound="GridView1_RowDataBound"
AllowSorting="True">
[code]....

Here's the code from the stored procedure:

ALTER PROCEDURE [dbo].[sp_GatewayMerchants]
-- Add the parameters for the stored procedure here
@StartDate DateTime,
[code].....

The datasource is passing 4 parameters, and the stored procedure is accepting 4, but when the page displays I get the error mentioned above.

EDIT: Here's the code behind for the template column. But I'm not sure how this could be causing extra parameters to the SP.

protected void Command_Click(object sender, EventArgs e)
{
var merchantID = Convert.ToInt32(((LinkButton)sender).CommandArgument);

[code].....

If I remove the ASP:LINKBUTTON the code works. So why would a LINKBUTTON be causing this?

View 4 Replies

Dynamic Parameters In A Stored Procedure?

Jan 19, 2011

I need to update a table with values from a listbox. I am trying to create as many parameters as there are items in the list, my code below, but how do i name them differently? so that they dont' overwrite each other?

For Each item As ListItem In ris
Dim pID As New SqlParameter("@userid", SqlDbType.Int)
pID.Value = objFormat.CheckSQL(item.Value)
myCommand.Parameters.Add(pID)
Next

and on the SQL side, is it possible to write an update statement, that will take a dynamic number of parameters?

so for example, i need to update multiple users with the same value in the "active" field...

View 3 Replies

Stored Procedure Call With Parameters In .NET MVC?

Apr 22, 2010

I have a working controller for another stored procedure in the database, but I am trying to test another.

When I request the URL; http://host.com/Map?minLat=0&maxLat=50&minLng=0&maxLng=50

I get the following error message, which is understandable but I can't seem to find out why it occurs;

Procedure or function 'esp_GetPlacesWithinGeoSpan' expects parameter '@MinLat', which was not supplied.

This is the code I am using.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; [code].....

View 2 Replies

Stored Procedure Parameters - Sometimes NULL?

Jan 19, 2011

i have a stored procedure to update a table. not all fields are required and some can be blank.for example, title is not required, but when it's blank i get an error

Dim ptitle As New SqlParameter("@title", SqlDbType.NVarChar, 20)
ptitle.Value = objFormat.CheckSQL(title)
myCommand.Parameters.Add(ptitle)
ex {"Procedure or Function 'sp_UpdateUser' expects parameter '@title', which was not supplied."} System.Exception


how can i fix it so that it allows for nulls if the data field is blank?

View 6 Replies

ADO.NET :: Unable To Use Stored Procedure With LINQ With 8 Parameters

Jan 29, 2011

I am working on LINQ. I am calling a SQL Stored Procedure with 2-3 parameters it's working fine. When i am going to call Stored Procedure with 8 to 9 parameters the auto generated column is not comming automatically. So i am unable to use LINQ with Stored Procedure with multiple parameters.

View 4 Replies

How To Call A Stored Procedure With Parameters From C# Code Behind

Sep 1, 2010

I have created a stored procedure shown below ,how will i call this from c# code behind to get the result and results are stored in dataset.

USE [Test]
GO
/****** Object: StoredProcedure [dbo].[tesproc] Script Date: 09/01/2010 13:00:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[tesproc]
-- Add the parameters for the stored procedure here
@a float, @b float, @c float,@d int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
select Id, Name1,ZipCode,StreetName,StreetNumber,State1,Lat,Lng, ( 6371 * ACOS( COS( (@a/@b) ) * COS( (Lat/@b) ) * COS( ( Lng/@b ) - (@c/@b) ) + SIN( @a/@b ) * SIN( Lat/@b ) ) ) as distance from business_details where ( 6371 * ACOS( COS( (@a/@b) ) * COS( (Lat/@b) ) * COS( ( Lng/@b ) - (@c/@b) ) + SIN( @a/@b ) * SIN( Lat/@b ) ) )<@d
END

If i execute this stored procedure in sql server its working fine with this following call

exec dbo.tesproc 12.9216667 ,57.2958,77.591667,1

View 2 Replies

SQL Server :: Adding Parameters To A Stored Procedure

Dec 23, 2010

I have a stored procedure which handles a SELECT query on an SQL 2005 table. Works fine. Now I need to add a bunch of parameters to the query--these are all boolean, with checkbox web controls on the .aspx page to set the parameters true or false, and bit columns in the SQL table. These parameters need to be optional, so that parameter doesn't filter out any records unless it's checked. Here's the original sproc:

[Code]....

Can I just add on all those boolean parameters like so?

[Code]....

View 10 Replies

SQL Server :: Stored Procedure With Multiple Parameters?

Nov 28, 2010

I have a table with 4 columns.The first column is a list of teams.The other three columns specify whether the team member with the particular id is present on any particular day .Say for example in the third row the running Team has 2 and 3 which means team member with the id 2 and 3 are present.Multiple values are seperated by the pipe symbol '|'.I have a Query like this

Select Teamname from tblTeam where Running not like '%|2|%' and Running not like '%|3|%' and Running not like '%|7|%' and Biking not like '%|1|%' and Biking not like '%|4|%' and Biking not like '%|7|%' and shooting not like '%|3|%' and shooting not like '%|4|%' and shooting not like '%|7|%' Basically i am searching the columns with like clause.The search criteria for each column may vary.In the above query i am searching for Teams where Running column does not contain 2,3 and 7,Biking column does not contain 1,4 and 7 and the shooting column does not contain 3,4 and 7. I would like to set a stored procedure where i would be able to pass 3 set of parameters from the code behind(I am using VB.net) for Running column search,Biking column search and the shooting column search.

Can someone tell me writing a simple stored procedure.I have a table with 4 columns.The first column is list of teams.The other three columns specify whether the team member with the particular id is present or not on any particular day .Say for example in the third row the running column has 2 and 3 which means team member with the id 2 and 3 are present.Multiple values are seperated by the pipe symbol '|'.

View 13 Replies

SQL Server :: Pass Stored Procedure Parameters Sometimes

Jan 28, 2011

Instead of dynamically building an sql to update data based on certain fields that are filled in, I would like to try and do it via a stored procedure I have three fields passing potentially passing to a stored procedure

myCommand.Parameters.AddWithValue("@Field1",
Field1.Text)

myCommand.Parameters.AddWithValue("@Field2",
Field2.Text)

myCommand.Parameters.AddWithValue("@Field3",
Field3.Text)

Stored Procedure accepts 3 parameters

@field1 nvarchar(20), @field2 nvarchar(20), @field3 nvarchar(20)

I want to be able to pass parameters in a variety of ways

field1, field2, field3
or
field1, field3
or
field2, field3

When I attempt thsi, it provides an error of a missing parameter when I do not supply all three. Is there any way to pass exclude parameters at times. The most important thing is that I do not want to update the field to a null when a parameter is not passed, I want it to exclude updating that field altogether

View 6 Replies

ADO.NET :: Passing Parameters To A Stored Procedure Using A SqlDataAdapter?

Dec 10, 2010

I am trying to create a method which will access the database via a SqlDataAdapter. I have passed two parameters month and year. When I run it, I get the error "Object reference not set to an instance of an object". I have posted the complete code below. Please take a look..

[Code]....

View 1 Replies

DataSource Controls :: How To Convert The Oracle Stored Procedure To Sqlserver 2005 Stored Procedure

Apr 2, 2010

This is surareddy. i nead some small clarification in the "Stored Procedure"

how to convert the oracle Stored Procedure to sqlserver2005/2008 Stored Procedure.

right now i am enhancing the project that project already developed the oracle Stored Procedure. now our company is using sqlserver 2005/2008.

how to convert the Oracle Stored Procedure to sqlserver 2005 Stored Procedure

View 4 Replies







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