I'm trying to update a single field in a table according to the an age
category as a condition.
The meat of the code that executes looks like this (I created a record
set, and loop through it until there are no records):
Code:
Do While Not rstRecSet.EOF
' gets the difference between todays date and db player date
intDifference = DateDiff("yyyy" , CDate(rstRecSet ("BIRTHDATE" )), Date)
If intDifference <= 8 Then
SQLUpdate = "UPDATE Player SET DIVISION = 'LEARN TO PLAY';"
ElseIf intDifference <= 10 Then
SQLUpdate = "UPDATE Player SET DIVISION = 'MITES';"
etc.....
End If
' execute my sql statement here to update record
oC.execute(SQLU pdate)
' move to next record to update....
rstRecSet.MoveN ext Loop
I did a response.write for the different in age and it shows the
difference between ages for all entries in the database (good), but it
will only update the first entry and set every single entry in the
database according to the first entry (so if the age difference is 17,
it will set the division properly, but every single record is going to
have that division name, regardless of their age category from the
first to last record).
Am I out to lunch here, on the right track? Is there possibly a better
way of doing this that I'm unaware of? An SQL update statement with
conditions?
Any sort of help would be appreciated. 1 1937
"davidevan" <de********@gma il.comwrote in message
news:11******** **************@ i42g2000cwa.goo glegroups.com.. .
I'm trying to update a single field in a table according to the an age
category as a condition.
The meat of the code that executes looks like this (I created a record
set, and loop through it until there are no records):
Code:
Do While Not rstRecSet.EOF
' gets the difference between todays date and db player date
intDifference = DateDiff("yyyy" , CDate(rstRecSet ("BIRTHDATE" )), Date)
If intDifference <= 8 Then
SQLUpdate = "UPDATE Player SET DIVISION = 'LEARN TO PLAY';"
ElseIf intDifference <= 10 Then
SQLUpdate = "UPDATE Player SET DIVISION = 'MITES';"
etc.....
End If
' execute my sql statement here to update record
oC.execute(SQLU pdate)
' move to next record to update....
rstRecSet.MoveN ext Loop
I did a response.write for the different in age and it shows the
difference between ages for all entries in the database (good), but it
will only update the first entry and set every single entry in the
database according to the first entry (so if the age difference is 17,
it will set the division properly, but every single record is going to
have that division name, regardless of their age category from the
first to last record).
Am I out to lunch here, on the right track? Is there possibly a better
way of doing this that I'm unaware of? An SQL update statement with
conditions?
Any sort of help would be appreciated.
You need a WHERE clause in your SQL to restrict the update operation to just
the record you are focused on.
UPDATE Player SET DIVISION = 'MITES' WHERE <identity=
<theplayerbeing processed>
--
Mike Brind This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Roy Adams |
last post by:
Hello people I've recently been woring with multiple insert from text
fields and got that woking fine thanks to the help from people from
this forum
now i'm trying to deal with multiple update, I'm pretty much using the
same script but it isn't working properly
I have a text field in a form with a text field called color, in a
repeated region, that shows the amount of colours for the item that
your viewing
it submits to another page that...
|
by: Roy Adams |
last post by:
Hi everyone
I'm trying to build a shopping cart app using a db the part I'm stuck
on is the fact that, if someone adds a product that they have
previously added to the cart.
I've got it set up to check whether the size and colour fields match
what's in the db, if they do then you've already added this item with
the same colours and size so, only update the quantity field, if they
don't match, then insert a new record because the size and...
|
by: anmar |
last post by:
I'm trying to figure out how to select all the records in one table
which have multiple specified records in a second table.
Here's a simplified version of my problem.
I have two tables, resources and goals.
resources table:
ID TITLE
|
by: Jeff |
last post by:
For years I have been using VBA extensively for updating data to tables
after processing. By this I mean if I had to do some intensive processing
that resulted in data in temp tables, I would have VBA code that wrote the
results of that away to the db, either creating new records or updating
existing records, whichever was relevant. This may also include deleting
records.
Now I generally do this by opening a recordset on the source data...
|
by: MP |
last post by:
Hi
trying to begin to learn database using vb6, ado/adox, mdb format, sql
(not using access...just mdb format via ado)
i need to group the values of multiple fields
- get their possible variations(combination of fields),
- then act on each group in some way ...eg ProcessRs (oRs as RecordSet)...
the following query will get me the distinct groups
| |
by: bbasberg |
last post by:
Hello,
I have been struggling with this problem for DAYS and have googled my heart out as well as reading any books I could get my hands on but I cannot find any specific references to my problem. I have been able to successfully loop through a directory reading spreadsheets that insert records into an Access database. The spreadsheets in said directory are all of the same format but have different values in the cells. It's when I turned...
|
by: shriil |
last post by:
Hi
I have this database that calculates and stores the incentive amount
earned by employees of a particular department. Each record is
entered
by entering the Date, Shift (morn, eve, or night) and the 'employee
name'. There is another table which assigns an ID to the Shifts, i.e.
1,2 and 3 for morn, eve & night shifts respectively. From the mother
table, the incentive is calculated datewise for each employee as per
his shift duty. In...
|
by: chimambo |
last post by:
Hi All,
I have a little problem. I am retrieving records from a table and I
want to update the records using checkboxes. I am able to display the
database record quite alright and I have created an array of
checkboxes, but my update loop is not working. Here is my code:
/*---------This retrieves the records -------------*/
if($row_md)
{
do{
echo "<tr><td text align='right'>";
|
by: Bill Schanks |
last post by:
I have a winform app (VB 2005) that allows users to export data to
excel, make updates to the excel file and import the data from that
Excel file and update the database.
My question is: Is it best to do it this way, calling the update
stored procedure for every update? Or should I be loading this data
into a staging table, and if all goes well do the 'Real' Update. Or
put this into a data adapter and update from that? The application...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |