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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

inserting/updating database

Status
Not open for further replies.

s4dadmin

Programmer
Apr 27, 2003
107
US
This is code for a calendar application that saves info to the database based on date. It is not giving an error when processed. Nothing is being inserted into the database and nothing is being updated either. Can anyone help?

Dim vDate
Dim chkTxt
Dim DiaryID
vDate = request("view_date")

Call OpenDB()
' Check to see if it's a new record to be added or an old one to update
StrSql= "Select * from diary where dte = '$vDate'"
set rs = DbConn.Execute (StrSql)
chkTxt = chkString(request("txt"))

if rs.BOF or rs.EOF then ' No records found. i.e. New record
StrSql ="INSERT INTO diary (dte, text_field) values ('" & vDate & "','" & chkTxt & "')"
else ' Record found. i.e. update record.
DiaryID = rs("id")
StrSql = "UPDATE diary SET diary.dte = '$vDate', text_field = '$chkTxt' WHERE id = '$DiaryID'"
End If

DbConn.Execute (strSql)
 
Also, I have verified that VDate shows a correct date but it only is entered as 0000-00-00 in the database. Should I use timestamp if time is not necessary?
 
Hi s4dadmin,

ASP date is not compatible with mysql but you will not receive an error message

To go around this problem, create a new variable


<%
Dim DateToday
DateToday = Year(Date()) & &quot;/&quot; & Month(date()) & &quot;/&quot; & Day(Date())
%>



then to insert your date


<%Response.Write(DateToday)%>


The rest of your code seems alright to me. try if the date is causing all malfunctions.


Bye


Qatqat



I have been happy throughout my life in thinking that samba was I kind of dance; now I live with Linux and all I do is working.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top