Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,


i written stored procedure with two select statements as below


ALTER procedure [dbo].[data]
@companyname nvarchar(50),
@countryid int,
@location nvarchar(50)
as
begin

select distinct top 8 (LocationName) ,CompanyName ,Count(LocationName) as LocationCount from Job where( CompanyName=@companyname ) group by LocationName,CompanyName Order by LocationCount desc


select distinct top 8 (CompanyName),LocationName,Count(CompanyName) as CompanyCount from Job where( LocationName=@location ) group by LocationName,CompanyName Order by CompanyCount desc



end







in single procedure now i want to bind it two different datalist,how can i do it using linq
Posted
Updated 29-Jun-14 23:38pm
v2

It should be possible to use the DataAdapter

C#
DbProviderFactory factory = DbProviderFactories.GetFactory("Your database provider name");
DbDataAdapter da = factory.CreateDataAdapter();

DbCommand cmd = connection.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "data";

DbParameter param1 = cmd.CreateParameter();
param1.DbType = DbType.String;
param1.Direction = ParameterDirection.Input;
param1.ParameterName = "@companyname";
param1.Size = 50;
param1.Value = "Your Company";
cmd.Parameters.Add(param1);

DbParameter param2 = cmd.CreateParameter();
param2.DbType = DbType.Int32;
param2.Direction = ParameterDirection.Input;
param2.ParameterName = "@countryid";
param2.Value = 0; 
cmd.Parameters.Add(param2);

DbParameter param3 = cmd.CreateParameter();
param3.DbType = DbType.String;
param3.Direction = ParameterDirection.Input;
param3.ParameterName = "@location";
param3.Size = 50;
param3.Value = "Your location";
cmd.Parameters.Add(param3);

DataSet ds = new DataSet();
da.SelectCommand = cmd;
da.Fill(ds);

DataTable dt1 = ds.Tables[0] // The first select
DataTable dt2 = ds.Tables[1] // The second select
 
Share this answer
 
v2
fetch all data into Dataset using dataadapter and sqlcommand. then bind one datalist with ds.tables[0] and 2nd with ds.Tables[1].

Please use this, it will solve your problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900