MySQL
  Home arrow MySQL arrow Two Lessons in ASP and MySQL
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MYSQL

Two Lessons in ASP and MySQL
By: Justin Cook
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 43
    2004-05-10

    Table of Contents:
  • Two Lessons in ASP and MySQL
  • It's a Date!
  • ¿Que Horas Son?
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Two Lessons in ASP and MySQL


    (Page 1 of 4 )

    ASP and MySQL are designed and distributed with completely different rationale, not to mention by two very different companies. But there is a good chance that you may want these two technologies for your dynamic application, in which case you need them to 'talk' to each other. One major obstacle to this could be that they differ in their handling of dates and times. This article will show you two functions you can implement to allow them to communicate peacefully, without trying to re-configure date/time formatting in either.

    I remember the initial rushed thrill that I experienced when I had the epiphany of installing MySQL on my home computer. I admit I didn't take it extremely seriously at the time, I just figured it would be an easy way of getting a nice application sandbox at home. But after using it for some time now, I am definitely a proponent of that beautiful open-source database. This article describes an unexpected situation I came up against and the two functions I whipped together to resolve those situations.

    To spoil any feelings of suspense that you may be already having, I'll tell you up front that the issue was with variations in handling date and time values. But how I came to have the problem is the exciting part (well, not really exciting, but valuable in the understanding of this situation).

    I decided that in my personal website and application it would be good to have some kind of user repository. No, I wasn't in any way expecting thousands of adoring fans flocking to my home page, but I was at least thinking that I could have a family and friends photo album, and they'd have to log in to see anything.

    So, I build my users table, with all fields pertinent to my users, and one more to track the date and time that their user profile was created. I set the field data type to datetime, as I'm used to doing with Access and the like. Then in my user creation script, I use the following lines to create each user (I'm omitting most fields for simplicity' sake):

    strSQL = "INSERT INTO users (email, pass, created) VALUES ( '" & _
       strEmail & "','" & _
       strPass & "','" & _
       Now() & "')"

    Do you see anything wrong with that? You shouldn't, because there's not. But then I take a look in my database, and everything has worked except for the datetime. All I see are a bunch of 0's! What the heck!!! OK, gathering my wits about me, I first turn with a suspicious look toward IIS; how dare it produce a string of 0's for the current date & time? But no, one line of

    debug( strSQL ) 'http://www.aspfree.com/c/a/ASP/Easy-Error-Management/3/

    shows me that everything is in order. So why is MySQL not storing the proper values; have I found a huge bug?

    But a second glance at the string of 0's brings a small revelation. The 0's are in a very distinct format, and distinctly different than how the datetime values appear with ASP, or even in Access. MySQL uses all dashes (-) as separators, instead of slashes and colons. Hmm, so all I needed was some kind of mediator between the two, something to do the conversion, so both ASP and MySQL could be happy with their native data formatting. I'll show you how I first took care of the date, then the time, then strung 'em together.

    More MySQL Articles
    More By Justin Cook


     

    MYSQL ARTICLES

    - MySQL and BLOBs
    - Two Lessons in ASP and MySQL
    - Lord Of The Strings Part 2
    - Lord Of The Strings Part 1
    - Importing Data into MySQL with Navicat
    - Building a Sustainable Web Site
    - Creating An Online Photo Album with PHP and ...
    - Creating An Online Photo Album with PHP and ...
    - PhpED 3.2 – More Features Than You Can Poke ...
    - Creating An Online Photo Album with PHP and ...
    - Creating An Online Photo Album with PHP and ...
    - Security and Sessions in PHP
    - Setup Your Personal Reminder System Using PHP
    - Create a IP-Country Database Using PERL and ...
    - Developing a Dynamic Document Search in PHP ...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT