Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
FillDataSet
Message
De
18/05/2009 18:03:04
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Divers
Thread ID:
01400227
Message ID:
01400531
Vues:
45
Your welcome Eric,

Glad you are onto better things.
Tim

>Thanks for the push, Tim. I'm so very brand new at .NET, and MM.NET.
>
>So I ended up exploring the overloaded functions to see what the possibilities were, and noticed the note in the MM help file saying that Entities/Entity Lists are really the way to go, so I changed things around. My function now looks like this:
>
>
>public mmBindingList<CustomerEntity> getCustomersByName(string cName)
>        {
>            return this.GetEntityList<CustomerEntity>("getCustomersByName", 
>                this.CreateParameter("@CustName", cName));
>        }
>
>
>and of course I had to write a back-end stored procedure, which looks like this:
>
>
>USE <i>MyDataBaseName</i>
>GO
>/****** Object:  StoredProcedure [dbo].[getCustomersByName]    Script Date: 05/18/2009 09:57:52 ******/
>SET ANSI_NULLS ON
>GO
>SET QUOTED_IDENTIFIER ON
>GO
>-- =============================================
>-- Author:		Eric Selje
>-- Create date: 5/18/2009
>-- Description:	Retreive membersList by name
>-- =============================================
>ALTER PROCEDURE [dbo].[getCustomersByName] 
>	-- Add the parameters for the stored procedure here
>	@CustName NVARCHAR(40)
>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 * FROM [dbo].[tblMember] WHERE txtParentCompName LIKE '%'+@CustName+'%' 
>		OR txtFacilityName LIKE '%'+@CustName+'%'
>END
>
>
>I feel like this is a better way to go, as its consistent w/ the stored procedures of the other methods and uses entity lists rather than datasets. I appreciate the guidance!
>
>Eric
>
>
>>You don't need to do it that way as the business objects know how to get a DataSet if that is what you want. Maybe something like this would get you there if you want to return a DataSet. Also, there are lots of overloads and some of those allow you to specify the CommandType. If in your business object you have the Default CommandType set to Stored Procedure, then you should specify here when you are doing something different. Your error is most likely because you are passing in a SQL Select statement when your default command type is set to Stored Procedure. Just use an overload to specify the CommandType or change your default setting to what you need it to be.
>>
>>Also, you can set the Default CommandType to one thing in the aBusinessObject, but if you have a business object specific you always use CommandType.Text, then change it in that business object. All that saves is not haveing to specify it at the Get methods with the overloads.
>>
>>In the business object method if you want to return a DataSet like your are specifing, then you could just use the GetDataSet method call like below or one of the overloads.
>>
>>
>>public DataSet GetCustomersByName(string cName)
>>{
>>    return this.GetDataSet("SELECT * FROM Customer", CommandType.Text);
>>}
>>
>>
>>
>>Also sometimes if I want a DataSet, I still just call a Get method to retrieve the entities so I can use the method in other places where I want entities. But if I need a DataSet in one paticular area of my application, I just get the dataset after the entities are retieved within the UI since the DataSet is sitting on the business object already at that point.
>>
>>In the business object method call GetEntityList and return that but in the UI you can then retrieve the DataSet from that.
>>Business Object method
>>
>>public mmBindingList<CustomerEntity> GetCustomersbyName(string cName)
>>{
>>  return this.GetEntityList("SELECT * FROM Customers", CommandType.Text);
>>}
>>
>>
>>Then in the Form you can call this and still get the DataSet
>>
>>oCustomer.GetCustomersByName(string cName);
>>// Now you can have the DataSet if you want to bind it something that way.
>>DataSet dsCustomers = this.oCustomer.DataSet;
>>
>>
>>Anyway, just some ideas.
>>Tim
>>
>>
>>>Can you use FillDataSet() if your business objects were setup to use stored procedures rather than SQL - SELECT?
>>>
>>>
>>>I've added this method to my business object:
>>>       public DataSet getCustomersByName(string cName)
>>>        {
>>>            this.FillDataSet(this.GetCurrentDataSet(),
>>>                    "SELECT txtParentCompName, txtMailAdd1, txtMailCity, txtMailState, txtMailZip, txtFacilityName, txtMemberType FROM Members WHERE txtName = '" + cName + "'", "crsCustomers");
>>>            return this.GetCurrentDataSet();
>>>        }
>>>
>>>
>>>but I get an error stating
Could not find stored procedure ''. "
in the FillDataSet() call.
Timothy Bryan
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform