Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Passing 2 parameters to DAL+ ExecuteReaderPassing 2 parameters to DAL+ ExecuteReader
Previous
 
Next
New Post
8/3/2009 1:48 AM
 

Hi!, I'm a complete beginner in module creation, and a bit also in .Net.

I've been following Michael Washington's tutorial on creaating a module using DAL+. The module is "ThingsForSale".
http://www.adefwebserver.com/DotNetNukeHELP/DNN_Things4Sale/Default.htm 
It worked well, and I really learned a lot. Thanks indeed Michael.

But now I want to add some "record filtering" capacity for the module.

I thought it was simply:
1- Add a parameter (@Description) to the Stored Procedure, and rewrite rhe SQL sentence to use the new parameter (using LIKE i.e.)
2- Add the same parameter in the SELECT DataObject Method in the "Controller" class
3- Re-define the ObjectDataSourse settings in the ascx file, so that it ties the new parameter to the Text property of the textbox used to filter.

I made all those things, but the module fails. I suppose it's because I'm using a wrong syntax in the DataObject Method, more specifically in the ExecuteReader. This is the code of the function:

<DataObjectMethod(DataObjectMethodType.Select)> _
Public Shared Function ThingsForSale_SelectAll(ByVal ModuleId As Integer, ByVal Description As String) As List(Of ThingsForSaleInfo)
Return CBO.FillCollection(Of ThingsForSaleInfo)(CType(DataProvider.Instance().ExecuteReader("ThingsForSale_SelectAll", ModuleId, Description), IDataReader))
End Function

As you can see I'm trying to pass the 2 parameters. I suppose I must pass some sort of Array, but I've been unable to figure it out how can I pass this Array.

I'm lost right now. That's why I came here. Please, tell me what am I doing wrong?

Thanks a lot.

Adrian.

 
New Post
8/3/2009 4:32 PM
 

This code looks ok, what is the error that you get?


-Mitchel Sellers
Microsoft MVP, ASPInsider, DNN MVP
CEO/Director of Development - IowaComputerGurus Inc.
LinkedIn Profile

Visit mitchelsellers.com for my mostly DNN Blog and support forum.

Visit IowaComputerGurus.com for free DNN Modules, DNN Performance Tips, DNN Consulting Quotes, and DNN Technical Support Services
 
New Post
8/4/2009 7:21 AM
 

Hi! Thanks for aswering.
The code is good, you are right. I saw another code from Michael Washington on the web where he uses the 2 parameters just putting them there, separated by commas: Using dr As IDataReader = DotNetNuke.Data.DataProvider.Instance().ExecuteReader("GetSurvey", SurveyID, ModuleId).

The error I get is that the set of records is always empty. Despite the text I put in the textbox I'm using in the ascx to be the "filter". Even leaving it empty.

I have this StoredProcedure for retrieving the records that will fill the GridView:

ALTER PROCEDURE [dbo].[D4010_ThingsForSale_SelectAll]
@ModuleId
int, @Description varchar(250)
AS
SELECT
ID, ModuleId, UserID, Category, Description, Price
FROM D4010_ThingsForSale
WHERE (ModuleId = @ModuleId) AND (Description LIKE '%@Description%')
ORDER BY Category

In the ascx I have this Textbox1, DataSource and GridView:

<
span class="style1">Description contains: </span>&nbsp;<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:Button ID="Button1" runat="server" Text="Buscar" /><br />

<asp:ObjectDataSource ID="ObjectDataSource_ThingsForSale" runat="server" DataObjectTypeName="YourCompany.Modules.ThingsForSale.ThingsForSaleInfo" DeleteMethod="ThingsForSale_Delete" InsertMethod="ThingsForSale_Insert" OldValuesParameterformatString="original_{0}" OnInit="Page_Load" SelectMethod="ThingsForSale_SelectAll" TypeName="YourCompany.Modules.ThingsForSale.ThingsForSaleController" UpdateMethod="ThingsForSale_Update"> <SelectParameters> <asp:Parameter DefaultValue="00" Name="ModuleId" Type="Int32" /> <asp:ControlParameter ControlID="TextBox1" DefaultValue="" Name="Description" PropertyName="Text" Type="String" /></SelectParameters> </asp:ObjectDataSource> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataSourceID="ObjectDataSource_ThingsForSale" DataKeyNames="ID,UserID,ModuleId" CellPadding="4" CellSpacing="1" Enableview_state="False"> <Columns> <asp:CommandField ShowDeleteButton="True" ShowSelectButton="True" /> <asp:BoundField DataField="ModuleId" HeaderText="ModuleId" SortExpression="ModuleId" Visible="False" /> <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" Visible="False" /> <asp:BoundField DataField="UserID" HeaderText="UserID" SortExpression="UserID" Visible="False" /> <asp:BoundField DataField="Category" HeaderText="Category" SortExpression="Category" /> <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" /> <asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" /> </Columns> <EmptyDataTemplate> There are no Things 4 Sale </EmptyDataTemplate> </asp:GridView>

I've tesed the thing putting the Description LIKE '%%' (empty string) in the Stored Procedure and it returns the complete set of records. So, the problem appears to be that I'm not being able to send the Textbox1.Text value to the Stored Procedure.

 

 

 

And this DataObject method:

<DataObjectMethod(DataObjectMethodType.Select)> _
PublicSharedFunction ThingsForSale_SelectAll(ByVal ModuleId As Integer, ByVal Description As String) As List(Of ThingsForSaleInfo)
Return CBO.FillCollection(Of ThingsForSaleInfo)(CType(DataProvider.Instance().ExecuteReader("ThingsForSale_SelectAll", ModuleId, Description), IDataReader))
End Function

 

 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Passing 2 parameters to DAL+ ExecuteReaderPassing 2 parameters to DAL+ ExecuteReader


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out