Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating a date

Status
Not open for further replies.

etjohnson81

Programmer
Jul 17, 2006
72
US
When I use this to update a date entered in a form, the value written to the database is 12/30/1899 and when read from the database, 12:00:37 A is returned.

Code:
regEmail= request.form("txtEmail")
homeEmail=request.form("txtEdumail")
memPersDesc=request.form("memPersDesc")
numMajID=request.form("selMajID")
dateBday=cdate(request.form("DateBday"))
memStrengths=request.form("memStrengths")
memInterest= request.form("memInterest")
updateSql="UPDATE tblStudent SET  "
'updateSql=updateSql + "txtStudentFname ='" & firstName &"', "
'updatesql=updatesql +" txtStudentLName ='"& lastName &", "
updateSql=updateSQL +" txtRegEmail ='"& regemail&"',"
updateSql=updateSql +" txtSecondaryEmail = '"& homeEmail &"', "
updateSql=updateSql +" memPersDesc = '"& memPersDesc & "',"
updateSql=updateSql +" numMajorID = "& numMajID &", "
updateSql=updateSql +" dateBday = "& dateBday & ", "
updateSql=updateSql +" memStrength = '"& memStrengths & "', "
updateSql=updateSql +" memInterests = '"& memInterst & "' WHERE numstudentID=" & session("numUserID") & ""
 
Add this and post the result here.

Response.Write(updateSQL)

Also, please indicate the type of database you are using, eg. SQL Server, Access, etc...

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
If your using VBScript in your ASP your using the wrong concatenation character (+ instead of &)

Code:
updateSql=updateSQL [COLOR=red]+[/color]" txtRegEmail ='"& regemail&"',"
updateSql=updateSql [COLOR=red]+[/color]" txtSecondaryEmail = '"& homeEmail &"', "
updateSql=updateSql [COLOR=red]+[/color]" memPersDesc = '"& memPersDesc & "',"
updateSql=updateSql [COLOR=red]+[/color]" numMajorID = "& numMajID &", "
updateSql=updateSql [COLOR=red]+[/color]" dateBday = "& dateBday & ", "
updateSql=updateSql [COLOR=red]+[/color]" memStrength = '"& memStrengths & "', "
updateSql=updateSql [COLOR=red]+[/color]" memInterests = '"& memInterst & "' WHERE numstudentID=" & session("numUserID") & ""

If your using Javascript your forgetting the semi-colons at the end of the lines and using some &'s instead of +'s for concatenation.

-T

signature.png
 
if you are using access database make sure you use # around your date field...

12/30/1899 is a default date which makes me think that your date variable is not getting populated correctly and is empty...

please do response.write on your variables and on your sql statements to see if everything is correct...

-DNG
 
thanks DotNet...that was the problem. It was doing math - 6 / 7 /1981. I did that and its fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top