Update Certain Field In Database

Nov 26, 2010

I want to create a web page using ASP.NET (C#, SQL queries) to keep track the login and logout time of all employees of a small store and total hours they work every day. Here are the fields in my table (employID, logintime, logouttime, totalhours). Once an employee log in, he just clicks the Login/Logout button. The program will store the current system time into the "logintime" field while leaving the "logouttime" field and the "totalhours" field empty until he clicks the button again at the end of the day. So when an employee clicks the button, I want to determine if he wants to login or logout by examing the "logouttime" field. If it's emty (NULL), I know he wants to logout. If the "logouttime" field is not empty, I know he wants to login so my progam will create a new entry for him. My question is, what is the best way to determine if he wants to login or logout? This is how I approach it:I create a SELECT query: "SELECT COUNT(*) FROM mytable WHERE logoutime IS NULL and employID = @employeeID" (this employeeID is the ID an employee uses to log in the web page). I use this "count" value to determine if the next operation is to let him logout or create a new entry. If count # 0, that means the employee needs to logout. I just need an UPDATE command to update value for logouttime field. I need another "SELECT * FROM mytable WHERE logouttime is NULL and employID= @employeeID" because my previous SELECT query returns only the count value. I will use a DataReader for the 2nd SELECT to walk through the fileds of the matched row to retrieve the value of "logintime" field for subtracting operation to get the total hours. Is there a way I can access the table to determine if the employee "logouttime" field is empty and at the same time using that open connection to retrieve his information if the "logouttime" field is empty? I hope what i'm trying to say make sense. I haven't coded it yet. Just logics at this point.

View 3 Replies


Similar Messages:

How To Update Database Field Every Year

Mar 24, 2011

I have a database which contains 2 fields called DateOfBirth and Age, for storing users DOB and age respectively. I want the Age column to be automatically incremented by 1 every year, according to the DOB matching server date.

What could be the best way for achieving this? I am using asp.net and sql server 2008.

View 1 Replies

Forms Data Controls :: Update Database Field With Textbox OnChange?

Jan 20, 2010

I've been searching for a tutorial or example on how to update my database when I change the text in the textbox that is in a DataList?

View 8 Replies

Data Controls :: Update Database Field And Label In GridView Using DropDownList

Feb 26, 2013

Am having one gridview. In that there is some details and one hyperlink (for Mail) and one Label (Mail Status).

The Mail status label have default value Not Sent for all fields. If i click the Mail link and send mail to the corresponding person, then the Default label value will be automatically changed its text to Sent.

View 1 Replies

Data Controls :: Update Database Field Using DropDownList In Edit ItemTemplate Of GridView

Mar 10, 2013

[URL]

but i wanted know,how to update the country of any customer by just choosing it from the dropdownlist and updating it in the databse.

i  wanted to add a common update below that updated the country of customers.

View 1 Replies

Data Controls :: GridView / Update Database Field Using DropDownList And Display It In Label In ItemTemplate?

Feb 23, 2013

i have three saved values in database 

1,2,3 

i want to showing status in label for 1 , Pending

 <asp:Label ID="lblLeaveStatus" Visible = "true" runat="server" Text='<%# Eval("Rec_Status").ToString() == "1" ? "Pending": Eval("Rec_Status") %>'>></asp:Label>

how can i show it with all 1,2,3?

View 1 Replies

Javascript - Make Code Works If Used Inside Update Panel And Checkbox Values Will Be Disabled According To Database Field?

Jan 28, 2011

This code works fine if i use this inside ssercontrol > panel and i have a checkboxes in table when no checkbox is checked its works fine .... but if i disabled and checked any of the textbox then this doesn't work .... in usercontrol why ? i didnt understand ..

<script type="text/javascript" language="javascript">
function checkboxChecked(){
var allInputs = document.getElementsByTagName("input");
for(var i=0; i<allInputs.length; i++) {
var chk = allInputs[i];
if(chk.type == "checkbox" && !chk.disabled && chk.checked) {

return true;
}
}
alert("OOps! You haven't selected all available checkboxes");
return false;
}
</script>

View 4 Replies

Architecture :: Database Update Table Field Time To Time

Feb 1, 2010

I need to do an update a field in database every x minutes. ie: a person login and I need to update a field related to they every X minutes until the value reach a value. Like this, this person start a count event from 1 to 10, they log off the web, but this count must remain countting until reachs 10, 1 by 1 every 7 minutes. I cannot do a SQL Job. Should I User a System.Timer??? Should I record the time and value of the last update, when the person log in I cauculate and update the value??

View 4 Replies

Way To Make Database Field A DateTime Field To String

Oct 5, 2010

Dim query as String = "Select * from openquery (devbook, 'SELECT wb.arrival_time FROM web_bookings wb ')"All I need is to convert my arrival_time into a datetime field in the query

View 1 Replies

DataSource Controls :: Update The Data Of A Database Through A Gridview Update Button?

Apr 19, 2010

i want to update the data of a database through a gridview update button

how can i attach a dataconvertion like this

[Code]....

View 1 Replies

Forms Data Controls :: How To Update Database In Datagrid By Clicking Single Update Button

Feb 21, 2011

i got a problem to update my database which i bounded to datagrid. The problem is, i want to update my database only by clicking one update button at the bottom.. when the user click it, all the fields will be updated to database.

View 3 Replies

DataSource Controls :: Cannot Update DataBase By Using UPDATE Query

Jul 6, 2010

[code]....

Im trying to update my DB(DataBase) by using SQL UPDATE query ,but its not updating in the dataBase i receive confirmation(in testLabel) that one row is affected(dataReader = query.ExecuteReader(); return numbers of rows affected)...

I have given a HTML editortext control on a page,which generates HTML (i have to store it in my DB,that page is only for Admin) ,on pressing Update button , im receving in my testLabel that one row is affected(which shows DB is updated succesfully) but when i check my DB its in old state,it is not updating...

Here is my Event handler of Update Button which have to make updates in DB:

[Code]....

[Code]....

View 2 Replies

DataSource Controls :: Update Field In Db?

Mar 14, 2011

I am facing problem in my update statement,

Dim abc As String
abc = Request.QueryString("str")
Dim userName As String = CStr(Session("user"))
Label2.Text = userName
Dim MyConnection As New OdbcConnection(ConnStr)
MyConnection.Open()
Dim MyCommand As New OdbcCommand
MyCommand.Connection = MyConnection
If MyCommand.CommandText = "Select userid from week where userid ='" & userName & "'" Then
MyCommand.CommandText = "Update week Set value = '" & abc & "' where userid ='" & userName & "'"
Else
MyCommand.CommandText = "INSERT INTO week (value, userid) VALUES('" & abc & "','" & userName & "')"
End If
MyCommand.ExecuteNonQuery()
MyConnection.Close()

View 18 Replies

ADO.NET :: How To Update A Single Field In The Db Table

Feb 22, 2011

net.3.5 linq 2 sql

if i need to update a single field in the db table - do i need to select all the row first?

can i say update myTable Field2 = x where field1=y?

dont know its look like too mach recourses

Order order =new ();
order.ID = 1; orderStatus = "test";
db.order.attach(order);
db.Refresh(RefreshMode.KeepCurrentValues, oOrder);
db.SubmitChanges();

well that delete all the other fields values

View 4 Replies

Cannot Update A Single Field Using Linq To Sql

Apr 25, 2010

I am having a hard time attempting to update a single field without having to retrieve the whole record prior to saving.

For example, in my web application I have an in place editor for the Name and Description fields of an object. Once you edit either field, it sends the new field (with the object's ID value) to the web server. What I want is the webserver to take that value and ID and only update the one field. There are only two ways google tells me to do this:

1) When I get the value I want to change, the value and the ID, retrieve the record from the database, update the field in the c# object, and then send it back to the server. I don't like this method because not only does it include a completely unnecessary database read call (which includes two tables due to the way my schema is).

2) Set UpdateCheck for all the fields (but the primary keys) to UpdateCheck.Never. This doesn't work for me (I think) due to my mapping layer between the Linq to Sql and my Entity/ViewModel layer. When I convert my entity into the linq to sql db object it seems to be updating those fields regardless of the UpdateCheck setting. This might be just because of integers, since not setting an int means it is a zero (and no, I can't use int? instead).

View 1 Replies

JavaScript Update Field In Another UserControl

Dec 20, 2010

I have one user control in page, and inside this have UC2 (modal pop up). And I try to achieve this: When I close UC2(modal) i try to update some fields on UC1. And this works fine for one(I have UC2(modal) and on button Save OnClientClick="SaveInfoCI()"), and in UC1 on top of page

function SaveInfoCI() {
document.getElementById("<%=frmData.FindControl("txtImplementingCI").ClientID%>").value
= document.getElementById("<%=UC2.GetClientID%>").value; }

but because i reuse this control in another place i want to update another field. Basically now i Have 3 JS function that update 3 fields. And I try when I click save in UC2(modal) I must execute one of this 3 javascript f, to update right field. I don't want to have 3 same UC with only difference in OnClientClick="SaveInfoCI().

View 1 Replies

AJAX :: Update Particular Field In UpdatePanel?

Nov 17, 2010

I have used update panel for my aspx page. I have 4 fields in update panel

- item code, item name, quantity,price

On Item Code changed i have implemented AJAX call to get Item name and price from DB.

I want to remove quantity field from async postback, so that it remains unchanged when AJAX call has been made.

View 3 Replies

Web Forms :: Updating Just One Field In The Gridview Update?

Aug 9, 2010

I was wondering if when you add the update link for gridview records, is there a way to only allow the user to update just one field in the record?

View 1 Replies

Web Forms :: Update Field With Name Of Signed In User

Jan 13, 2011

Using the form view control, when I click on the edit button to modify a record. the form is in update mode. When I clcik the update button any modified data is posted, but, for some reason the name in one filed named, user_update_name, does not. The name in the field will not change unless the field was empty. For example, if test1 was the last user to modify the record and the user_update_name field was empty, the field was now say Test1. If Test2 modified the same record, Test1 name will still display in the field. The command that fires when the update button is clicked.

Imports System.Data
Imports System.Data.Common
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient
Imports Microsoft.VisualBasic
Protected
Sub FormView1_ItemUpdating(ByVal sender
As System.Object,
ByVal e
As System.Web.UI.WebControls.FormViewUpdateEventArgs)
Handles FormView1.ItemUpdating
frmPartsDS.UpdateParameters("user_update_name").DefaultValue = User.Identity.Name
End
Sub

View 3 Replies

DataSource Controls :: Update Tabel Field?

Dec 25, 2010

i need to update one field in a tabel just to +2 and i can not find out how to do it the code i have write until now is just to find the field i has to update this i the code

[Code]....

write the last code there can +2 to a.point field in my db

View 2 Replies

SQL Server :: CommandType.StoredProcedure Won't Update Field?

Jan 28, 2011

A text field on a webform "txtFirstName" contains the value "Sue". I change it to "Mary" and initiate the code below. It stays as "Sue" When I run in debug mode, I see that the tex property of "txtFirstName" is still "Sue" even though the web page clearly displays "Mary"

Why doesn't it update?

-- ASP.NET CODE --

Dim conn As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString)
Dim myCommand As New SqlCommand("client_profile", conn)
myCommand.CommandType = CommandType.StoredProcedure[code]....

View 4 Replies

Web Forms :: Getting Value From Hidden Field In Update Panel

Feb 29, 2012

I have 2 text controls one visible & other hidden & a button1 wuth client click   in update panel

when the user enters the value in visible text control & clicks button1 the value is passed to the hidden field & i get value in the hidden field

outside the update panel there is one more command button with server side click event

on command button click i need to get values of the hidden field in server side which currently i am getting blank

I even tried by putting the command button in another update panel

but still i get blank

View 1 Replies

Web Forms :: Automatically Update Data Source According To Another Field?

Jul 28, 2010

There is a field called school which is a dropdown menu, I manually edit items and made it like these: select school, name of 6 elementaries and 2 middle schools, and a high school.I have another field called grade level, which is a drop down menu too, i manually entered the grade items for it: select grade, Kindergarten, 1, 2, 3......12.

I would like after user selects a school in the drop down menu, the field called grade level dropdown box' data source will be updated according to school. For example, if it is a middle school selected, the data source of grade level will be updated to 6, 7 8 grade, if it is elementary the grade will be updated to 1, 2, 3, 4 5 etc. In this way later, when user goes to select grade it will show appropriate grade level lists according to schools.

View 10 Replies

Forms Data Controls :: Update Field Based On Value In Another?

Apr 9, 2010

In GridView (using VB) , I have project information, with Status and %Complete that the user is supposed to update. Trouble is they may change %Complete to 100%, but not change the status from Active to Complete. So, we wind up with a long list of Active tasks that are 100% Complete. How can I force an update to the Status field ? something like... If "%Complete" = "100" Else Status = "Complete" Not sure if I need to do this in VBscript or code behind or SQL or.

View 2 Replies

DataSource Controls :: Update A Field That Isn't In The Row Using A Button In Gridview?

Oct 28, 2010

I have a gridview which shows a list of data... at the end of each item I have added a button which is linked to the onclick event... when a button is clicked I want a value to update on that specific row... but I can't get it to work :( my code is below...

SqlDataSource 1 code...

UpdateCommand="UPDATE [PurchaseProduct] SET [BDConfirmSent] = 'Yes' Where [Id] = @Id">
<UpdateParameters>
<asp:Parameter Name="Id" />
<asp:Parameter Name="BDConfirmSent" />
</UpdateParameters>

Code Behind...

Protected Sub SqlDataSource1_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource1.Updating
e.Command.Parameters("@BDConfirmSent").Value = "Yes"
End Sub
Protected Sub Button1_Click()
SqlDataSource1.Update()
End Sub

When I click the button it just postsback the page but then the [BDConfirmSent] field is still empty instead of being "Yes"

View 4 Replies







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