Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 22nd, 2008, 09:10 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

If you look up VBScript functions you will find things like the trim function (removes leading and traling white space) however the other two are simple ones I have written. I keep these in a global functions file, include it in all the pages and call then where neccesary. They are:

  Function StoreText(theText)
    StoreText = ""
    on error resume next
    StoreText = CStr(theText)
    if (len(StoreText) > 0) Then
      StoreText = Replace(StoreText, """", """, 1, -1, 1)
      StoreText = Replace(StoreText, "'", "''", 1, -1, 1)
      StoreText = Replace(StoreText, vbCrLf, "<BR>", 1, -1, 1)
    end if
  End Function

This function simply uses the replace function to change ' to '' and vbCrLf to <bR> etc. I wrap this function around ALL strings going nto my DB

Here is the amDate function:

  FUNCTION amDate(varDate)
    IF isNull(varDate) OR Trim(varDate) = "" OR varDate = "Null" THEN
       amDate = "Null"
    ELSE
       amDate = "" & Month(DateValue(varDate)) & "/" & Day(DateValue(varDate)) & "/" & Year(DateValue(varDate)) & ""
    END IF
  END FUNCTION

This simply uses the dateValue, day, month and year functions to ensure what ever valid date is passed goes into the DB as dd/mm/yyyy

use them like so:

myFieldName='" & trim(storeText(request.form("myFormElementName"))) & "'

myFieldName=#" & amdate(request.form("myFormElementName"))) ) & "#" (into ACCESS)
myFieldName='" & amdate(request.form("myFormElementName"))) ) & "'" (into SQLServer)

Wind is your friend
Matt
www.elitemarquees.com.au
 
Old April 22nd, 2008, 11:34 PM
Authorized User
 
Join Date: Apr 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thats some great info. Thanks a bunch!






Similar Threads
Thread Thread Starter Forum Replies Last Post
MS ACCESS 2003 FRONTEND AND MS SQL SERVER 2005 DB mohankumar0709 SQL Server 2005 3 March 23rd, 2007 12:48 AM
Ms Access DB in Server anukagni Access 2 February 24th, 2006 02:15 AM
MS Access db on a website lawrenceh VB Databases Basics 0 September 25th, 2004 06:32 PM
JDBCRealm using MS access DB ZouK01 Java Databases 0 May 26th, 2004 02:01 PM
JDBCRealm using MS access DB ZouK01 Apache Tomcat 0 May 26th, 2004 01:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.