|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
MySQL and ASP
I am trying to add a "dynamic" date to my MySQL DB. A user inputs a date in txtfield1 fills out the rest of the info...clicks "next".
"Next" brings them to a verify page (page 2) where they can essentially "preview" the goods. If it looks good, they click finish (which takes them to page 3) and the junk gets thrown into the DB. Here's my problem. From page 1 - page 2...the data seems to be flowing well enough. From screen page 2 - 3, the data flow works and prints out on screen -- the way it should. HOWEVER...none of the date is being inputed into the DB. Code below is from all 3 pages: -------------Page 1 ----------------- <form name="frmInfo" id="frminfo" method="post" action="verify.asp"> <select name="month"> <select name="day"> <select name="year"> <select name="Hour"> <select name="minute"> <input type="submit" name="Submit" value="Submit Information" onclick="frmInfo.submit()"/> blah blah blah.... --------------Page 2 ---------------- varMonth=request.form("month") varDate=request.form("day") & ", " & request.form("year") varTime=request.form("hour") & ":" & request.form("minute") & " " & request.form("ToD") varEvent=request.form("event") varDescription=request.form("description") <form name="frmsubmit" id="submitevents" method="post" action="submitevents.asp"> <input name="txtDate" type="hidden" value= <% request.form("year") & "-" & request.form("month") & "-" & request.form("day") %> /> <input name="txtTime" type="hidden" value= <% response.write varTime %> /> <input name="txtEvent" type="hidden" value= <% response.write varEvent %> /> <input name="txtDescription" type="hidden" value= <% response.write varDescription %> /> etc.... --------------Page 3 ----------------- strDate=request.form("txtdate") strTime=request.form("txtTime") strEvent=request.form("txtevent") strDescription=request.form("txtdescription") Dim dbconn, strSQL strSQL = "INSERT INTO tblevents (eventid, varDate, event, varTime, description) VALUES (" strSQL = strSQL & "Null" strSQL = strSQL & ", ' " & request.form("txtdate") & "', '" strSQL = strSQL & request.form("strtime")& "', '" strSQL = strSQL & request.form("strevent") & "', '" strSQL = strSQL & request.form("strdescription") & "')" Set dbconn = Server.CreateObject("ADODB.Connection") connstr = "DSN=events; UID=iisuser; pwd=" dbconn.open connstr dbconn.execute strSQL, connstr dbconn.close Set dbconn = nothing I can't seem to find the problem. The only thing I can think of, is that I am not providing either the correct format for the date or special characters. When I do a record submission THROUGH MySQL, I get the following line....(but keep in mind that everything was static). INSERT INTO tblevents (eventid, vardate, vartime, event, description) VALUES (NULL, '2003-08-23', '08:00 PM\r\n', 'nothing ', 'more to say either.\r\n') I know it's a lot to swallow...but...Any thoughts? |
|
#2
|
|||
|
|||
|
I would also like to mention I am aware of the request.form mistakes in the "Page 3" section. One last thing to mention, which I forogt...My dates show up in the DB, but only as 0000-00-00 which it's telling me, I am getting a connection to the thing.
|
|
#3
|
|||
|
|||
|
Hello,
If you are using MySQL then as far a VB is concerned I insert date using format function as below strSQL = "INSERT INTO tblevents (eventid, varDate, event, varTime, description) VALUES (" strSQL = strSQL & "Null" strSQL = strSQL & ", '" & Format(request.form("txtdate"), "YYYYMMDD") & "', '" strSQL = strSQL & request.form("strtime")& "', '" strSQL = strSQL & request.form("strevent") & "', '" strSQL = strSQL & request.form("strdescription") & "')" because MySQL accepts date in the above format i.e. YYYYMMDD and I doubt if it accepts "Null" just check out about Null but I am sure about the Date format. Now if there is format provision in asp (as far as my logic is concerned it has to be there) you use the format and it will definetely work. 101% sure of it. |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > MySQL and ASP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|