Can ObjectDataSource Use Table-valued Parameters
Oct 15, 2010
If an ASP.NET web page uses an ObjectDataSource, can you configure it to use a stored procedure that uses table-value parameters?
User-defined type:
CREATE TYPE [dbo].[integer_list_tbltype] AS TABLE
(
[n] [int] NOT NULL,
PRIMARY KEY CLUSTERED
)
Stored procedure:
CREATE PROCEDURE [dbo].[GeneralReport]
@intList integer_list_tbltype READONLY
AS
BEGIN
SELECT * FROM ...
END
ASP.NET
<asp:ObjectDataSource ID="GeneralDataSource" runat="server"
SelectMethod="GetDataByRange"
TypeName="MyProject.GeneralDataSetTableAdapters.GeneralViewTableAdapter"
>
<SelectParameters>
<asp:Parameter Name="intList" />
</SelectParameters>
</asp:ObjectDataSource>
I've tried hooking into the ObjectDataSource's Selecting event like this:
[code]....
be set for UDT parameters." being thrown
View 2 Replies
Similar Messages:
Oct 13, 2010
I'm trying to figure out if it's possible to use an ObjectDataSource Update method with a table-valued parameter. Here's my ODS:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DataObjectTypeName="TestProject.MyTestDataTable"
SelectMethod="GetTestData" TypeName="TestProject.BLL.TestBLL"
OldValuesParameterFormatString="original_{0}"
UpdateMethod="UpdateTestData">
<SelectParameters>
<asp:Parameter DefaultValue="65" Name="testId" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
I bind this to a GridView but I'm not looking to edit row by row. Instead my GridView has a bunch of TemplateFields with textboxes. I also have a Button that when pressed, invokes the Update method of the ODS. So then the "UpdateTestData" function in my TestBLL is called. This looks like this:
public void UpdateTestData(MyTestDataTable dt)
{
QueriesTableAdapter qta = new QueriesTableAdapter();
qta.UpdateTestData(dt);
}
At run-time in debug, it seems like the object for the signature above is not populated with the data from my GridView.
View 1 Replies
May 19, 2010
This is my first attempt in using table valued parameters in my stored procedures. Please find the scripts down below. The idea is very simple. I'm trying to insert a new product into Products table and if the product has attributes, I'll insert them into ProductAttributes table which is where I use table-values parameters.
I was able to test the stored procedure manually. It's working fine. So the error must be in the C# code but there's not much to it.
Here's the DAL code in C# that calls the stored procedure:
[Code]....
Just in case you need it, here's what my Product object looks like:
[Code]....
And the ProductAttribute object is even simpler:
[Code]....
Here's the SQL scripts to create the tables, stored procedure and user defined table type:
[Code]....
View 4 Replies
Sep 29, 2010
I have a checkboxlist that gets all all the items from a look up table. The user is going to go to the list, check certail items and insert the checkboxid, the value (0 or 1), and the userid into a table valued paramater using a stored procedure. I have the user defined table type created but thats about it. Any body out there have any hints.
View 4 Replies
Jan 27, 2011
I am trying to develop a function that returns a table. I have written: -
[code]...
I am using SQL Server 2008 V2 Express, but my production database is SQL 2005 so solutions will need to be compatible with that.
View 6 Replies
Jan 21, 2011
know if the followin is supported in .net framework 4.0?I have a sql stored procedure with one of its parameter as Hierarchy data type( i suppose its a table valued parameter).. trying to drag this stored procedure onto my linq design studio is not being allowed?
View 1 Replies
Nov 25, 2010
I need to pass a table type parameter to a user-defined table valued function in SQL Server 2005.How would I do this?
My function name is udf_t_GetSales ( @financialYearMonthsData as table)
The table @financialYearMonthsData has 3 columns ( MonthId int, DisplayText nvarchar(500), CalendarYear int)
View 7 Replies
Jul 9, 2010
I would like to know which one is better, table-valued function or View, in terms of perfomance.Earlier I have created view which is performing cross join (which takes time) and 2/3 Left outer join and it's taking time. To reduce execution time I have created table-valued function with parameter to reduce cross join execution time and it returns the same result as view.Just give me an idea about table-valued function and View, in terms of perfomance. Which one is better?
View 1 Replies
Apr 22, 2010
[code]....
Select method returns array of strings . But How I need to appear selected node for edit delete methods get this string (userName) ?
for methods like :
[DataObjectMethod(DataObjectMethodType.Delete, true)]
static public DeleteMember(...
View 1 Replies
Aug 9, 2010
I followd Brian Orrell LINQ tutorial for paging/sorting and created a gridview bound to an ObjectDataSource through a method call which gets data from adatabase. My form includes two buttons with a textbox next to each one of them. I need to be able to populatte th egridview depending on the button that was pressed, I cannot figure out how signal my method which button was pressed.
[Code]....
[URL]
View 1 Replies
Feb 16, 2010
http://msdn.microsoft.com/en-us/library/ms178538(VS.80).aspx ?I tried and got error as below, at clicking Update button in detailView
'/CaseExamples' 응용 프로그램에 서버 오류가 있습니다. ==> Server error in application program
ObjectDataSource 'EmployeeDetailsObjectDataSource'에서 매개 변수 (LastName, FirstName, Address, City, Region, PostalCode, original_FirstName, original_LastName, original_Address, original_City, original_Region, original_PostalCode, original_EmployeeID)를 사용하는
네릭이 아닌 UpdateEmployee' 메서드를 찾을 수 없습니다.
View 3 Replies
Feb 16, 2011
[Code]....
When I want to get the output values its okay but I also want returning a table as a result data.But Datareader has no rows.is it possible if I want a returning query result and multiple output values togather ?I wrote a test above.I can get output values as sqlparameters. But Datareader attached to a Gridview is empty.can you detect whats wrong here and it doesnt return a query result.So stored procedure is not standart or ı am doing something wrong.this doesnt raise any exception.but not returning any data.
[code]....
View 8 Replies
Feb 28, 2010
I have a DetailsView control with a SelectMethod and two select parameters wich one of the parameters is a control parameter, The parameters are not passed to objectDatasource's select method, the objectdatasource has been defined as follows:
<asp:ObjectDataSource ID="objCurrCompetitor" runat="server" SelectMethod="GetCompetitorByUserAndCompetition"
DeleteMethod="DeleteCompetitor"
TypeName="MZ.Competitions.BLL.Main.Competitor"
[code]...
View 2 Replies
Jun 23, 2010
I've a form view with various field in edit and an object datasource where I've defined my update parameters that my update method takes. I've set some of the fields in the edit template to read only because I want them to display.
Unfortunately they are getting passed in as update parameters somehow to my objectdatasource.
So, it is generating update parameters that causes my method to not match.
How can I exclude these parameters from getting sent to update?
View 1 Replies
Feb 16, 2010
I have a gridview databound to an objectdatasource. Everything worked great until I changed 2 columns from asp:BoundField to asp:TemplateField. These are the UPC column and the Part column. I wanted to show a link button for each of these fields that take the user to another page. Now asp.net expects these two fields to be parameters on the update store procedure. Why is this? How do I get it to not assume these columns need to be passed to the store procedure?
Here is the code for the grid view:
[code]....
View 1 Replies
Dec 10, 2010
I'm trying to use an objectdatasource and populate it with a query that has "or" in its where statement. eg: select * from customers where customer_id = "34" or "35" or "36"The problem is... I don't know ahead of time how many of these "or" conditions there will be - the user can choose as many or as few as they want. It seems that if I want to use an objectdatasource tied to a tableadpater I'm forced to know the number of parameters ahead of time so that I can build the objectdatasource's input parameters e.inputparameters.add doesn't work, because the key (in this case "id") is the same for each parameter because the where statment has "or"s....
View 7 Replies
Mar 27, 2011
how to pass parameters to the selectmethod property of the objectdatasource control.
View 1 Replies
Mar 30, 2011
When using parameters in an ObjectDatasource for an RDLC report, how can you get the parameter values and display them in the report?
View 1 Replies
Mar 7, 2014
I Bind CheckBox List With Employee through Database
I Want To get Selected Item valued hence
i write a code behind button click
foreach (ListItem item in cblEmployee.Items)
{
if (item.Selected)
{
string id = item.Value;
}
}
but instead of check we get Selected Property False and execution does not go in if Condition
View 1 Replies
Dec 15, 2010
I have an ASP.NET 3.5 web form with a DropDownList bound to a table of company names in a database. I also have a data bound GridView which I would like to update with data from the database depending on the company name selected in the DropDownList, so that the SelectCommand for the GridView's SqlDataSource is:
SELECT Registration, Telephone, Profile FROM {CompanyName}_VehicleData
Where {CompanyName} is whatever is selected in the DropDownList. I've used the Command and Parameter Editor to create a ControlParameter pointing to the SelectedValue of the DropDownList, but I don't know how to write the SelectCommand query to concatenate the parameter to '_VehicleData'.
View 1 Replies
Sep 16, 2010
I want to query an SQL table using some Web controls to provide the parameters for filtering the records in the table. Results are displayed in a GridView.
I have a TextBox with an ID of "keyword" where the user may enter one or more keywords. I'd like to search 2 columns for instances of these keywords.
I also have a DropDownList named "category" that lists categories contained in a "category" column of the table.
I have a dataset with a TableAdapter for the table I want to search. Got it working fine with the DropDown List but not sure how to proceed with the TextBox and keywords.
What SQL query should I use? The user may not enter anything into the textbox, they may enter one word, or multiple words.
This is where I am now:
SELECT * FROM tablename WHERE category = @category AND ??
View 7 Replies
Sep 18, 2010
SO I have created an object data source on a page from a table adapter using the various Wizards in Visual Studio.
Its meant to query a diary Database by a DateTime parameter called diaryDate. I want to query from a date Now to the next 14 days ahead.
I want to display the entries in a Grid View when the page loads.
So I'm a bit stuck now as to how to set the two query parameters date1 and date2. I want to set date1 = now() and date2 = now() + 14 days.
How do I set those parameters when the page loads ?
Should I have used the adapter Wizard approach of do I have to write all the code in the code behind page ??
This is my datasource code'
[Code]....
This is my query string,
[Code]....
View 1 Replies
Feb 21, 2011
i want to get one value from function using case statement,i tried it but not work
CREATE FUNCTION [FATMS].[fnReturnByPeriod]
(
@Period INT
) [code]....
View 2 Replies
Dec 14, 2012
I have a class User as ahown bellow.
Public class User {
public string userName { get; set ; }
public string userId { get; set; }
}
Once user logins i am populating userName, userId
And storing user class object in to session.
session["User"] = objUser
I have another Class Consumer as shown Bellow.
Public Class Consumer {
//constructors
public Consumer(User user) {
// some code goes Here.
}
}
I am Using spring frame work To initialize the class using dependency injection.
So my question is how can i pass stored user session to constructor using springs.
same config is given below.
<object id="objConsumer" type ="Namesapce.consumer, consumer"> <constructor-arg Value="User"/> </object>
View 1 Replies
Nov 19, 2010
I have the following XML:
<IncidentEntity>
View 2 Replies