Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Valid user input
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01173034
Message ID:
01173043
Vues:
9
>I have users that input these data into a form at the same time:
>
> Machine Start Time End Time
>user 1 01 1430 1545
>user 2 02 1500 1630
>user 3 01 1600 1648
>etc.
>
>If by mistake user 2 inputs Machine 01 (it's already working)
>
>How do I prevent that data from being stored using the insert sentence ?
>There is no primary key to compare user's input.


How do you know it's already working so it's a wrong entry? Because it fits in the current time?
Do a query before inserting to see if the current time fits in a slot for the machine number you want.

Something like
nMachine = 1
mytime = strtran(left(Time(),5),":","")
cSQL = "select * from mytable where machine="+transform(nMachine);
" and dt between StartTime and EndTime"
or you can say dt < = EndTime and dt > = StartTime

If you get a record returned then it's already in use.

This assumes time in the current day, as per your data sample.


Alex Feldstein, MCP, Microsoft MVP
VFP Tips: English - Spanish
Website - Blog - Photo Gallery


"Once again, we come to the Holiday Season, a deeply religious time that each of us observes, in his own way, by going to the mall of his choice." -- Dave Barry
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform