Question Question about Count and some others

waterbottle

New member
Joined
Nov 20, 2011
Messages
3
Programming Experience
Beginner
jgjpdt.jpg

this is roughly the add form where i have created... i am suppose to send this information into the database that i am using which is mysql.
It is suppose to grab the incident date and the Type and also a count that increases by 1 if the date is the same or else it will be back to one.
v2tdp0.jpg


the question is that my count does not increase and also how do i make it check the code and increase by 1 count or change the count back to one if the date is different?
Also how do i remove the slashes in the date so it only takes out the numbers?

14ln8sx.jpg


Thanks in advance.
 
It looks like your 'count' variable is local, so it gets created anew, and therefore initialised to zero, each time you call that method. If you want a variable to maintain its value between method calls then it must be declared outside of your methods.

What does "check the code" mean?

You can call the ToString method of a DateTime value and specify whatever format you want. That said, you should not be storing dates and/or times as text in a database. They should be stored as binary dates and times. That's how they should be treated in the app too. To that end, you should be using DateTimePickers rather than TextBoxes for your dates and times.
 
where do i declare it? sorry for being a novice
the criteria that im trying to make is to use the last date used. may i have an example on how to create a if statement with the criteria that is mentioned below? [if date is used before, the count will +1 else if date haven been used before, it will be 1.] Also as the "GuestID" will be something like "FHS-201011-1". Please advice Thanks
may i also have an example of the ToString method to datetime?
Thanks in advance!
 
Are you saying that you don't know the difference between inside and outside? It's currently inside the method (presumably) and you need to move it outside. That's all.
 
Back
Top