Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8617051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:45:55+00:00 2026-06-12T05:45:55+00:00

Below is an example of using the stored procedure(GetTimesWithCustomerNames) then via ArrayList collecting data

  • 0

Below is an example of using the stored procedure(GetTimesWithCustomerNames) then via ArrayList collecting data retrieved by the query:

/*
    GetTimesWithCustomerNames 3571, 6, 2012, 1
    GetTimesWithCustomerNames '3571', '6', '2012', '0'

*/
ALTER PROCEDURE [dbo].[GetTimesWithCustomerNames]
@userid int=0, @month int=0, @year int=0,@reasonid int=0
AS
BEGIN
    SET NOCOUNT ON;

    if @userid!=0 begin

        create table #tmp (tId int, UserId int, 
        TimeIn1 smalldatetime, [TimeOut1] smalldatetime, 
        TimeIn2 smalldatetime, [TimeOut2] smalldatetime, tId2 int,
        TimeIn3 smalldatetime, [TimeOut3] smalldatetime, tId3 int,
        ActiveDate smalldatetime, ReasonID int, Name nvarchar(100), ReasonType nvarchar(100),
        TotalMins int)

        insert into #tmp (tId, UserId, TimeIn1, TimeOut1, ActiveDate, ReasonID, Name, ReasonType)
        SELECT
        t1.tId, t1.UserId, t1.TimeIn, t1.[TimeOut], t1.ActiveDate, t1.ReasonID, tblCustomers.Name,
        (select reasontype from tblTimeReas where ReasonID=t1.ReasonID) as ReasonType
        FROM tblTime t1
        inner join tblCustomers on t1.UserId=tblCustomers.custID
        where (t1.userid=@userid)
        and (DATEPART(MONTH,t1.timein)=@month or @month=0)
        and (DATEPART(YEAR,t1.timein)=@year or @year=0)
        and (t1.reasonid = @reasonid or @reasonid=0)        
        and
        (select COUNT(1) from tblTime t2 where userid=@userid and datediff(day,t2.TimeIn,t1.TimeIn)=0 and t2.tId<t1.tId)=0

        update #tmp
        set tId2 = (select top 1 tId from tblTime t2 where userid=@userid and DATEDIFF(day,t2.timein,#tmp.timein1)=0
                        and t2.tId>#tmp.tId order by tId asc)
        update #tmp
        set tId3 = (select top 1 tId from tblTime t3 where userid=@userid and DATEDIFF(day,t3.timein,#tmp.timein2)=0
                        and t3.tId>#tmp.tId2 order by tId asc)

        update #tmp
        set TimeIn2 = (select TimeIn from tblTime where tId=tId2),
            TimeOut2 = (select [TimeOut] from tblTime where tId=tId2),
            TimeIn3 = (select TimeIn from tblTime where tId=tId3),
            TimeOut3 = (select [TimeOut] from tblTime where tId=tId3)

        update #tmp set TotalMins = (
            isnull(DATEDIFF(minute,timein1,timeout1),0)+
            isnull(DATEDIFF(minute,timein2,timeout2),0)+
            isnull(DATEDIFF(minute,timein3,timeout3),0)
        )

        select * from #tmp order by TimeIn1
        drop table #tmp

    end

END

I would like to know, for given userid I can have all data returned into an ArrayList – what is the way to retrive a set of values per userid ? Will it be possible to have a data returned per user(few) in an arrayList and not for one only like this procedure ?

In this query data is TimeIn TimeOut ActiveDate etc…

  • ReEditing
    I think my question is should the task be for the code behind in a foreach loop or would it be possible to modify the procedure to accept more than one userid?

The code I am using to store data in code behind is:

 public static ArrayList loadData(string sql)
    {

        DBManager dbManager = new DBManager(DataProvider.SqlServer, "Data Source=(local);Initial Catalog=databaseName;Integrated Security=True");

        ArrayList data = new ArrayList();

        try
        {
            dbManager.Open();
            dbManager.ExecuteReader(System.Data.CommandType.Text, sql);
            while (dbManager.DataReader.Read())
            {
               Hashtable x = new Hashtable();

                for (int i = 0; i < dbManager.DataReader.FieldCount; i++)
                {
                    x.Add(dbManager.DataReader.GetName(i), dbManager.DataReader.GetValue(i));
                }
                x.Add("COUNTER", data.Count+1);
                data.Add(x);
            }
        }
        catch { data = null; }
        finally
        {
            dbManager.Dispose();
        }

        return data;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:45:57+00:00Added an answer on June 12, 2026 at 5:45 am
        public static List<Dictionary<string, object>> loadData(string sql)
        {
    
        itson = (sql.StartsWith("GetTimesWith"));
        DBManager dbManager = new DBManager(DataProvider.SqlServer, "Data Source=(local);Initial Catalog=hental;Integrated Security=True");
    
        //ArrayList data = new ArrayList();
        List<Dictionary<string, object>> data = new List<Dictionary<string,object>>();
        try
        {
            dbManager.Open();
            dbManager.ExecuteReader(System.Data.CommandType.Text, sql);
            while (dbManager.DataReader.Read())
            {
               //Hashtable x = new Hashtable();
               Dictionary<string, object> x = new Dictionary<string, object>();
                for (int i = 0; i < dbManager.DataReader.FieldCount; i++)
                {
                    x.Add(dbManager.DataReader.GetName(i), dbManager.DataReader.GetValue(i));
                }
    
                x.Add("COUNTER", data.Count+1);
                data.Add(x);
                ncx = data.Count;
    
            }
        }
        catch { data = null; }
        finally
        {
            dbManager.Dispose();
        }
    
        return data;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below is a simplified example of a stored procedure I've created. DELIMITER // CREATE
The example below shows the code I am using to test whether a user
In the example below, if client code using GetPeople wanted to print the name
Below I'm using simple example, real tables are bigger, I cannot store devices in
I need to create a stored procedure which takes 12 arguments and the query
I have a data struct being stored in JSON format, converted using the serializeJSON
I am writing a stored procedure using MySql which returns multiple rows using select
Let's consider the below example. There, I have: target MAIN calls target t and
How can I get only unique departments from the below example? Dept Id Created
Reproducible example below. I have a simulation loop, within which I occasionally have rows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.