Highlighted Row, Increment Variable

May 5, 2008

I have an asp.net with C# code behind page that displays the following. The information
is being pulled from an SQL database. Each row that is above 7:10am is highlighted.:

EntryDate    EntryTime     Employee
4/25/08      7:05:56 AM   
Scot                  
4/25/08      7:11:02 AM    Rick       
4/26/08     
9:05:00 AM    Jen                       
4/27/08      8:05:16 AM   
Mel                       
4/27/08      7:15:06 AM   
Bill                       
4/28/08      5:00:55 AM    Scot
I want to have a static variable for each employee called lateScot, lateJen, lateMel, lateRick, lateBill. For each row that is highlighted, I want to increment the counter of the employee by one. I am using the RowDataBound event to highlight as needed. But how can I use the SqlDataSource1_Selecting event to go through the and increment as needed based on highlighted rows?
 
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
    {
       
    }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string grr = e.Row.Cells[2].Text;

            DateTime ontime = Convert.ToDateTime(e.Row.Cells[1].Text);
            DateTime late = Convert.ToDateTime("12/30/1899 7:10:00 AM");
            
            if (ontime.TimeOfDay >= late.TimeOfDay && grr != "Mailman,Mailman" && grr != "Moses,Bill" && grr != "Bathroom,Women's" && grr != "Bathroom,Men's" && grr != "Sharm,Tonmoy")
            {
                e.Row.BackColor = System.Drawing.Color.Firebrick;
                e.Row.ForeColor = System.Drawing.Color.White;
            }                       
        }
    }
 
Thanks in advance,
Scot
 

View 3 Replies


ADVERTISEMENT

Increment A Variable

Jul 19, 2007



Hi,



How do I increment the value of a variable? let's say from initial value of var1 = 0 it becomes 1



Thanks!



cherriesh

View 8 Replies View Related

Insert Increment Variable

Oct 31, 2007



This is on SQL 2000 and 2005. I need to increment a variable on insert, but am having a hard time getting a workable solution:

declare @var int
set @var = (select max(id) from table1)

insert into table1

select val1,

@var +1 as val2
from table2
where blah and blah and blah

If I were trying to insert val1's of (5, 10, 20) with @var having an initial value of 100, the added rows should be:

val1 val2
5 101
10 102
20 103

Does anyone know how to do this without temp tables (or table variables)?



View 5 Replies View Related

How To Increment SSIS Variable (Date)

Apr 11, 2008

My requirement demands me to use a extract based on a date. And on success i need to increment this date by a day.
So i have a declared two variables, vDate and vSourceSQL. I am using the sql statement from variable in the data access method. My package is successful.
Reading through the forum and after following this blog
http://blogs.conchango.com/jamiethomson/archive/2005/02/09/SSIS_3A00_-Writing-to-a-variable-from-a-script-task.aspx
i now have a script task which will increment my "vDate" variable and i am calling it as a post execute task. I have posted the error below. Tried to get atleast the sample provided to succeed, but.... this is what i get.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Information: 0x4004300B at Data Flow Task, DTS.Pipeline: "component "Flat File Destination" (800)" wrote 12 rows.
Error: 0xC001405C at Script Task Data Flow Task: A deadlock was detected while trying to lock variables "User::vMyVar" for read/write access. A lock cannot be acquired after 16 attempts. The locks timed out.
Error: 0xC001405D at Script Task Data Flow Task: A deadlock was detected while trying to lock variables "System::InteractiveMode" for read access and variables "User::vMyVar" for read/write access. A lock cannot be acquired after 16 attempts. The locks timed out.
Error: 0x2 at Script Task Data Flow Task: The script threw an exception: A deadlock was detected while trying to lock variables "User::vMyVar" for read/write access. A lock cannot be acquired after 16 attempts. The locks timed out.
Task failed: Script Task Data Flow Task
Warning: 0x80019002 at OnPostExecute: The Execution method succeeded, but the number of errors raised (5) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
Warning: 0x80019002 at SqlCommandFromVariable: The Execution method succeeded, but the number of errors raised (5) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
SSIS package "SqlCommandFromVariable.dtsx" finished: Failure.
The program '[2316] SqlCommandFromVariable.dtsx: DTS' has exited with code 0 (0x0).
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

View 7 Replies View Related

Report Wizard - No 'Next' Button Highlighted On Last Screen

May 21, 2007

Hi,



I am trying to use the report wizard and I get to the last screen where it asks for a name for the report file. The 'Next' button is not unprotected although the 'Finish' button is.



As far as I can tell I have setup the Matrix style report up correctly. If I use the 'Finish' button, Visual Studio just crashes.



The help does not give any clue and I have not found any answers in the forum.



Any ideas what the problem might be?

View 3 Replies View Related

SSDT In Visual Studio 2012 - Selected Identifier Is Not Highlighted

Jan 22, 2015

In VisualStudio 2012 in C# projects when you double-click on a identifier (variable name, class name, etc) then all occurrences of that sting in the current file are highlighted.

It doesn't work in SQLServer projects in sql files. It is a shame that although we are in VisualStudio we are still limited in functionality.

Is there a way to enable this feature?

View 4 Replies View Related

Microsoft SQL Server Migration Assistant For Access: No Convert Schema Highlighted?

Dec 6, 2006

Hi all,

I downloaded the Microsoft SQL Server Migration Assistant for Access 4 weeks ago. Today, I tried this program for the first time.  I added one Database with 3 Access 2003 Tables to the Access Metadata Explorer.  I right clicked Databaes on the Access Metadata pane and did not see the "Convert Schema" highlighted!!!???  What is wrong with the program? How can I make it highlighted?   Please help and advise.

Thanks in advance,

Scott  Chang 

 

View 8 Replies View Related

Need To Have 2 Auto Increment Columns (Seed, Increment)

Dec 11, 2007

Hello,

I Have a table that needs to have 2 unique number.

detail_id and detail_print_id.

detail_id is already an IDENTITY.

both fields need to be different, because when importing, it imports the same data into a table twice, with only a slight data change (and id is not one of the changes).

So I thought i could do the following:

detail_id INT NOT NULL IDENTITY(1,2),
detail_print_id INT NOT NULL IDENTITY(2,2),
--blah blah

that way, the detail_id will always be odd, and the detail_print_id will always be even. however SQL Server 2005 only allows 1 identity per table, and both these fields need to be auto generated when the field is inserted, so as to prevent double data.

is there anyway I can create a int column to auto increment, without the column being an IDENTITY??

also, I would prefer to not have to create a second table with a single column just for this work.

Thanks,
Justin

View 5 Replies View Related

Select For Cursor Returns 0 Same Select Highlighted Returns 2,000+

Jul 23, 2005

Grrr!I'm trying to run a script:print 'Declaring cursor'declare cInv cursor forward_only static forselectdistinctinv.company,inv.contact,inv.address1,inv.city,inv.state,inv.postalcode,inv.cmcompanyidfromdedupe.dbo.ln_invoice as invleft joindedupe.dbo.customerid as cidondbo.fnCleanString(inv.company) = cid.searchcowhere((inv.customerid is nulland cid.searchco is null)and (inv.date >= '01/01/2003' or (inv.date < '01/01/2003' andinv.outstanding > 0.01))and not inv.company is null)print 'Cursor declared'declare@contact varchar(75),@company varchar(50),@address1 varchar(75),@city varchar(30),@state varchar(20),@zip varchar(10),@cmcompanyid varchar(32),@iCount int,@FetchString varchar(512)open cInvprint 'cursor opened'fetch cInv into@company,@contact,@address1,@city,@state,@zip,@cmc ompanyidprint 'Cursor fetched @@Cursor_rows = ' + cast(@@cursor_rows asvarchar(5))All the prints are there to help me figure out what's going on!When I get to the Print 'Cursor fetched @@cursor_rows....the value is 0 and the script skips down to the close and deallocate.BUT, if I just highlight the Select...When section, I get over 2,000rows. What am I missing?Thanks.

View 6 Replies View Related

T-SQL Increment

Oct 11, 2005

i have got 22,000 rows in a table, i want to update the records to have to start id of 70000 which increments to 70001, 70002 ? how would i go about doing this ?

View 3 Replies View Related

Increment A Value

Sep 30, 2006

Is there an easy and fast way to increment a value by 1 in a database? For example if a value is 106 I will need to make it 107. Is there a fast way to do this?

View 9 Replies View Related

Increment The Value

May 9, 2008

If there is one field such as Seq No in a table and if we entered some data ..
and if we update one record of Seq No then the below records of Seq No should be incremented in that table

for example there are 10 seq no's and if i had updated the seq no 4 to 5 then the
5 shuld b inc 6 and 6 to 7 etc............

at preasent i wrote only
update in sp of that particular record:
like this

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go


ALTER PROCEDURE [dbo].[UpdateSelected]
(

@Description NVARCHAR(30),
@SequenceNo int
)
AS

UPDATE Sequence SET
Description = @Description,
SequenceNo = @SequenceNo

WHERE
SectionID = @SectionID
but now i need additional functionaly like inc the remaining sq no above that given no...

Regards,
Anushka

View 1 Replies View Related

How To Increment The Row

Jun 12, 2008

1. I have a table lets say ABC in which the datatype of one of the column lets say MNO is int identity.
3. Inserted some records into this table using SSIS. the values in the column MNO are from 1 till 20
2. i want insert more records into this table ABC using SQL task in SSIS
How do i do this. can any body help me out.

Thanks in advance

View 1 Replies View Related

Row Increment

Jun 12, 2008

1. I have a table lets say ABC in which the datatype of one of the column lets say MNO is int identity.
3. Inserted some records into this table . the values in the column MNO are from 1 till 20
2. i want insert more records into this table ABC
How do i do this. can any body help me out.

Thanks in advance

View 2 Replies View Related

Getting The Next Increment

Sep 7, 2007

I have a table with an automatic count int. What I want to know is there an sql statement to return the next increment from the sequence. Any help would be appreciated.

View 4 Replies View Related

Sum With Increment

Mar 8, 2006

TO allI have tabelautonumber value1125364859610712813981010and if i want sum with increment 2autonumber value1 - 2 1 + 5 = 63 - 4 6 + 8 = 145 - 6 197 - 8 259 - 10 18please help.............. trims

View 5 Replies View Related

Increment A Value

Oct 1, 2007

Hi,

This is my first SSIS query. I have just started with ssis and have the following task

I am looping text files in a folder using foreach. I transfer text file data to sql server. I want to count the total rows are that transferred in all the text files after the foreach loop finishes. I user RowCount but it gives count of only current textfile. It gets reset each time the loop iterates. I want something like @count = @count + currentnoofrows in current text file.

lalit.

View 5 Replies View Related

SSIS Script Task Alters Package Variable, But Variable Does Not Change.

Oct 25, 2006

I'm working on an SSIS package that uses a vb.net script to grab some XML from a webservice (I'd explain why I'm not using a web service task here, but I'd just get angry), and I wish to then assign the XML string to a package variable which then gets sent along to a DataFlow Task that contains an XML Source that points at said variable. when I copy the XML string into the variable value in the script, if do a quickwatch on the variable (as in Dts.Variable("MyXML").value) it looks as though the new value has been copied to the variable, but when I step out of that task and look at the package explorer the variable is its original value.

I think the problem is that the dataflow XML source has a lock on the variable and so the script task isn't affecting it. Does anyone have any experience with this kind of problem, or know a workaround?

View 1 Replies View Related

Passing A SSIS Global Variable To A Declared Variable In A Query In SQL Task

Mar 6, 2008

I have a SQL Task that updates running totals on a record inserted using a Data Flow Task. The package runs without error, but the actual row does not calculate the running totals. I suspect that the inserted record is not committed until the package completes and the SQL Task is seeing the previous record as the current. Here is the code in the SQL Task:

DECLARE @DV INT;
SET @DV = (SELECT MAX(DateValue) FROM tblTG);
DECLARE @PV INT;
SET @PV = @DV - 1;

I've not been successful in passing a SSIS global variable to a declared parameter, but is it possible to do this:

DECLARE @DV INT;
SET @DV = ?;
DECLARE @PV INT;
SET @PV = @DV - 1;


I have almost 50 references to these parameters in the query so a substitution would be helpful.

Dan

View 4 Replies View Related

How To Increment ID Sequentially?

Nov 21, 2006

I'm using SQL Server 2000 with MS Management Studio. I have a table that has 400 rows. I have setup the Primary key to increment automatically. How do I setup so that the next record starts at 4001 and up? Right now it starts at 1274, for example. So besides dropping the table and re-creating it, how do reset it so it counts from sequentially from the last row inserted?

View 5 Replies View Related

How To: SP To Increment Through A Table

Jul 19, 2007

How can you increment row by row through a table using a stored procedure?
I am trying this but getting error on SET statement - Line 6: Incorrect syntax near '.'.
PROCEDURE asuodem.spA_LinkSpinner ASWHILE (tblLinkInfo_OLD2.L_ID IS NOT NULL)BEGINIF (tblLinkInfo_OLD2.L_Rank > 10) AND (tblLinkInfo_OLD2.L_Rank < 300)SET tblLinkInfo_OLD2.L_Rank = Convert(int, (250-25+1)*RAND())ELSE CONTINUEENDRETURN
 

View 10 Replies View Related

Auto Increment

Mar 24, 2008

 DIAGID is the
field in database which is integer. i want to increment this when page is
loaded.but it is not working..

plz
find mistake ... thanks in advance

 

SqlCommand sqlCmd = new SqlCommand("Select max(DIAGID)  from tblDxactual",
sqlCon);

       
SqlDataReader sqlDr;

       
sqlCon.Open();

       
sqlDr = sqlCmd.ExecuteReader();

       
if (sqlDr.Read())

       
{

           
txtbxDiagID.Text = sqlDr[0].ToString()+ "1"
;    

       
}

       
else

        
txtbxDiagID.Text="1";

       
sqlCon.Close();

View 3 Replies View Related

MS-SQL: Where's Auto Increment?

Feb 4, 2005

It's been a long time since I've had to check an index for the highest value, then add 1, to create a new unique key. These past few years, it seems this is usually done for you. But now that I'm working with MS-SQL, I don't see it. Is it there? It's doesn't seem to be inherent in the definition.

View 5 Replies View Related

MS SQL 05 Auto Increment

Jan 26, 2006

Hello,
Firstly Hello to everyone I'm new the forum and fairly new to .net
I'm working on web datbase application using visual studios 05 and MS SQL05 I've used 2003 (briefly) before but 2005 is very new to me.
To my problem I download the GUI interface from microsoft so I can now setup a local database and do my own testing.
I have created the table and fields with in it however on a particular table i have made a primary Key and left it as an INT but I would like to set it as auto increment ! I dont know how to select that option as i was used to mysql way of doing things or does this have to be done as a stored procedure ?
Any assistance much appreciated.
 

View 1 Replies View Related

Auto Increment.... Key&#39;s... Etc..

Apr 4, 2001

I am very new to using SQL server 7. I've always used mysql in the past. I cant figure out howto create a autoincrementing key for my tables... is it possible to do in SQL7?? If so.. how.. i thought you just set the datatype to auto increment etc...

sorry for any oversights...


dave

View 1 Replies View Related

Identity Increment

Aug 22, 2000

Hello!

I is true that SQL-Server use lower values than last integer value (in auto incremet field). Is there option that i could prevent that. So the Server would always put + 1 for the auto increment value.

Thanks

Juissi

View 2 Replies View Related

Auto Increment

Sep 23, 2002

I would like to avoid using a cursor. I am updating several rows in a table with sequential numbers starting at a number I pass into the Stored Procedure. Is there a way to do this with one update statement?

Thanks,
Ken Nicholson
Sara Lee Corporation

View 3 Replies View Related

Auto-Increment

May 30, 2008

Hey,

Here is what happened:

Users for a long time have been able to post new topics in our forums. However, a short time ago, the some users began to experience problems. What I have narrowed it down to is that upon inserting into the table, sometimes id value for the topic is the same as an id that is already in the table, so it fails to insert the record (due to a constraint). However, the topic id column is an auto-increment column and should just assign the next number for the id value.

Any ideas?

View 3 Replies View Related

Identity Increment

Oct 13, 2005

If delete all the records from a table that has an incremental identity. Is there a TSQL way of reset the first number on an insert back to be 1 again without going to the table taking it off then saving it the putting it back on again?

View 2 Replies View Related

Increment In A Trigger?

Feb 23, 2013

I have the following table:

Code:

CREATE TABLE [dbo].[apcName](
[SysID] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[RIN] [int] NOT NULL,
[Name] [varchar](80) NOT NULL,
[DimTab] [tinyint] NOT NULL,

[code]....

If I have an Insert trigger to set the RIN field to the next available number in the sequence of the RIN column, why does the following work for inserting 1 and only 1 record at a time but fails if doing multiple rows with a single insert?

Code:
-- Insert Trigger
UPDATE xRec
SET RIN = (Select MAX(RIN) + 1 from apcName)
FROM apcName xRec
JOIN inserted ins
ON ins.sysID = xRec.sysID

-- Works, RIN is populated correctly

Code:
Insert apcName (Name, DimTab) VALUES ('Test Name', 1)

Does Not Work. Returns 1 for all RIN's

Code:
Insert apcName (Name, DimTab) VALUES
('Test Name1', 1),
('Test Name2', 2)

View 14 Replies View Related

Auto Increment

Mar 15, 2006

I have important a table from mircosoft access into ms sql server 2000, I've created a new ID row and set the primary key - but I need to use the ID from microsoft access as well. therefore I'd like to add an auto increment +1 on the old access ID field... but how do I do that?

View 1 Replies View Related

Please Tell Me How To Auto Increment

Nov 6, 2006

hi, i have columns(name,id,salary) in my emp table,see to that there is no primary key in my table, but i want to do auto increment, in my table id has to be auto incremented,so please give me coding to do that,pleaseeeeeeee

View 3 Replies View Related

SQL To Increment Salary

Sep 26, 2007

i want to write a SQL statement to increment the salary by 10% for technicians who have done three tests on a particular date.

there are two employee types.(1)technicians (2)traffic controllers.
employee category is defined in "Type" attribute of Employee table. the increment should happen only to technicians.thank you in advance.

Employee (EmployeeID,Name,Salary,Tpye)

TestEmployee(TestNo,EmployeeID,Hrs)

Test(TestNo,TestDate,Result)

View 20 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved