Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: insert date into access


Message #1 by dont worry <aspmailbox@y...> on Tue, 27 Nov 2001 15:16:41 -0800 (PST)
I have date/time field in access, I get insert error

if I leave date blank.  I have to enter #my/date/here#

or I get error.  How do I avoid this error?

Thanks



__________________________________________________

Do You Yahoo!?

Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.

http://geocities.yahoo.com/ps/info1

Message #2 by "Kim Iwan Hansen" <kimiwan@k...> on Wed, 28 Nov 2001 00:44:22 +0100
your date/time field in access has probably "required" set to "yes" - set it

to "no" instead to allow no dates to be inserted.



-Kim





-----Original Message-----

From: dont worry [mailto:aspmailbox@y...]

Sent: 28. november 2001 00:17

To: ASP Databases

Subject: [asp_databases] insert date into access





I have date/time field in access, I get insert error

if I leave date blank.  I have to enter #my/date/here#

or I get error.  How do I avoid this error?

Thanks



Message #3 by dont worry <aspmailbox@y...> on Wed, 28 Nov 2001 07:40:42 -0800 (PST)
Kim,

It is set to no.  Here is the insert statement and it

only gives error when BirthDate is missing.  Is there

something I could enter?



INSERT INTO MembersTable (UserID , Password ,

FirstName , LastName , Gender , DateofBirth,

EmailAddress , Address , City , Country , State ,

PostalCode , PrimaryPhone , SecondaryPhone, FaxPhone ,

CreditCardNum , CreditCardExp, ProductAmount,

Occupation, CreatedDTM, ModifiedDTM, CreatedBy) VALUES

('t3', 'pass', 't3' ,'t3', 'female', , 't3@t...' , '

' , '' , '' , '' , '' , '', '', '' , 545 ,

#2002/02/01# , 2.00 , '' , #11/28/2001#, #11/28/2001#

, 'WebForm' ) 



--- Kim Iwan Hansen <kimiwan@k...> wrote:

> your date/time field in access has probably

> "required" set to "yes" - set it

> to "no" instead to allow no dates to be inserted.

> 

> -Kim

> 

> 

> -----Original Message-----

> From: dont worry [mailto:aspmailbox@y...]

> Sent: 28. november 2001 00:17

> To: ASP Databases

> Subject: [asp_databases] insert date into access

> 

> 

> I have date/time field in access, I get insert error

> if I leave date blank.  I have to enter

> #my/date/here#

> or I get error.  How do I avoid this error?

> Thanks

> 

> 

>  



> aspmailbox@y...


> $subst('Email.Unsub')

> 

> Read the future with ebooks at B&N

>

http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&categoryid=rn_ebooks





__________________________________________________

Do You Yahoo!?

Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.

http://geocities.yahoo.com/ps/info1

Message #4 by "Kim Iwan Hansen" <kimiwan@k...> on Wed, 28 Nov 2001 17:17:29 +0100
You need to insert NULL instead of the date when there's no date present.

So check if anything was entered, otherwise set dtmDOB to NULL.



-Kim





-----Original Message-----

From: dont worry [mailto:aspmailbox@y...]

Sent: 28. november 2001 16:41

To: ASP Databases

Subject: [asp_databases] RE: insert date into access





Kim,

It is set to no.  Here is the insert statement and it

only gives error when BirthDate is missing.  Is there

something I could enter?



INSERT INTO MembersTable (UserID , Password ,

FirstName , LastName , Gender , DateofBirth,

EmailAddress , Address , City , Country , State ,

PostalCode , PrimaryPhone , SecondaryPhone, FaxPhone ,

CreditCardNum , CreditCardExp, ProductAmount,

Occupation, CreatedDTM, ModifiedDTM, CreatedBy) VALUES

('t3', 'pass', 't3' ,'t3', 'female', , 't3@t...' , '

' , '' , '' , '' , '' , '', '', '' , 545 ,

#2002/02/01# , 2.00 , '' , #11/28/2001#, #11/28/2001#

, 'WebForm' )



--- Kim Iwan Hansen <kimiwan@k...> wrote:

> your date/time field in access has probably

> "required" set to "yes" - set it

> to "no" instead to allow no dates to be inserted.

>

> -Kim

>

>

> -----Original Message-----

> From: dont worry [mailto:aspmailbox@y...]

> Sent: 28. november 2001 00:17

> To: ASP Databases

> Subject: [asp_databases] insert date into access

>

>

> I have date/time field in access, I get insert error

> if I leave date blank.  I have to enter

> #my/date/here#

> or I get error.  How do I avoid this error?

> Thanks

>

>

>



> aspmailbox@y...


> $subst('Email.Unsub')

>

> Read the future with ebooks at B&N

>

http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&categoryid

=rn_ebooks





__________________________________________________

Do You Yahoo!?

Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.

http://geocities.yahoo.com/ps/info1








$subst('Email.Unsub')



Read the future with ebooks at B&N

http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&categoryid

=rn_ebooks



Message #5 by "Tomm Matthis" <matthis@b...> on Wed, 28 Nov 2001 11:30:47 -0500
Does the field allow NULL values? If not then change the field specs.



-- Tom



> -----Original Message-----

> From: dont worry [mailto:aspmailbox@y...]

> Sent: Tuesday, November 27, 2001 6:17 PM

> To: ASP Databases

> Subject: [asp_databases] insert date into access

> 

> 

> I have date/time field in access, I get insert error

> if I leave date blank.  I have to enter #my/date/here#

> or I get error.  How do I avoid this error?

> Thanks

> 

> __________________________________________________

> Do You Yahoo!?

> Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.

> http://geocities.yahoo.com/ps/info1

> 

>  




> $subst('Email.Unsub')

> 

> Read the future with ebooks at B&N

> http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&ca

tegoryid=rn_ebooks



Message #6 by dont worry <aspmailbox@y...> on Wed, 28 Nov 2001 13:26:06 -0800 (PST)
Kim and Tim

Access 97,

Required set to NO

Default Value set to NULL

Indexed Yes(Duplicates OK)

I even put asp 

if dbDOB = "" Then

   dbDOB = NULL

end if

and it still doesn't work?  I don't want to resort to

putting a fake date?  What should I try?

Thanks

--- dont worry <aspmailbox@y...> wrote:

> Kim,

> It is set to no.  Here is the insert statement and

> it

> only gives error when BirthDate is missing.  Is

> there

> something I could enter?

> 

> INSERT INTO MembersTable (UserID , Password ,

> FirstName , LastName , Gender , DateofBirth,

> EmailAddress , Address , City , Country , State ,

> PostalCode , PrimaryPhone , SecondaryPhone, FaxPhone

> ,

> CreditCardNum , CreditCardExp, ProductAmount,

> Occupation, CreatedDTM, ModifiedDTM, CreatedBy)

> VALUES

> ('t3', 'pass', 't3' ,'t3', 'female', , 't3@t...' ,

> '

> ' , '' , '' , '' , '' , '', '', '' , 545 ,

> #2002/02/01# , 2.00 , '' , #11/28/2001#,

> #11/28/2001#

> , 'WebForm' ) 

> 

> --- Kim Iwan Hansen <kimiwan@k...> wrote:

> > your date/time field in access has probably

> > "required" set to "yes" - set it

> > to "no" instead to allow no dates to be inserted.

> > 

> > -Kim

> > 

> > 

> > -----Original Message-----

> > From: dont worry [mailto:aspmailbox@y...]

> > Sent: 28. november 2001 00:17

> > To: ASP Databases

> > Subject: [asp_databases] insert date into access

> > 

> > 

> > I have date/time field in access, I get insert

> error

> > if I leave date blank.  I have to enter

> > #my/date/here#

> > or I get error.  How do I avoid this error?

> > Thanks

> > 

> > 

> >  



> > aspmailbox@y...


> > $subst('Email.Unsub')

> > 

> > Read the future with ebooks at B&N

> >

>

http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&categoryid=rn_ebooks

> 

> 

> __________________________________________________

> Do You Yahoo!?

> Yahoo! GeoCities - quick and easy web site hosting,

> just $8.95/month.

> http://geocities.yahoo.com/ps/info1

> 

>  



> aspmailbox@y...


> $subst('Email.Unsub')

> 

> Read the future with ebooks at B&N

>

http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&categoryid=rn_ebooks





__________________________________________________

Do You Yahoo!?

Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.

http://geocities.yahoo.com/ps/info1

Message #7 by "Philip Sayers" <philipsayers@m...> on Wed, 28 Nov 2001 16:28:36 -0500
Have you tried putting in the date delimiters but with nothing between

them?  I see in your SQL below, you don't have delimiters on the missing

date, but you have delimiters on the missing strings.





-----Original Message-----

From: dont worry [mailto:aspmailbox@y...]

Sent: Wednesday, November 28, 2001 4:26 PM

To: ASP Databases

Subject: [asp_databases] RE: insert date into access



Kim and Tim

Access 97,

Required set to NO

Default Value set to NULL

Indexed Yes(Duplicates OK)

I even put asp

if dbDOB = "" Then

   dbDOB = NULL

end if

and it still doesn't work?  I don't want to resort to

putting a fake date?  What should I try?

Thanks

--- dont worry <aspmailbox@y...> wrote:

> Kim,

> It is set to no.  Here is the insert statement and

> it

> only gives error when BirthDate is missing.  Is

> there

> something I could enter?

>

> INSERT INTO MembersTable (UserID , Password ,

> FirstName , LastName , Gender , DateofBirth,

> EmailAddress , Address , City , Country , State ,

> PostalCode , PrimaryPhone , SecondaryPhone, FaxPhone

> ,

> CreditCardNum , CreditCardExp, ProductAmount,

> Occupation, CreatedDTM, ModifiedDTM, CreatedBy)

> VALUES

> ('t3', 'pass', 't3' ,'t3', 'female', , 't3@t...' ,

> '

> ' , '' , '' , '' , '' , '', '', '' , 545 ,

> #2002/02/01# , 2.00 , '' , #11/28/2001#,

> #11/28/2001#

> , 'WebForm' )

>

> --- Kim Iwan Hansen <kimiwan@k...> wrote:

> > your date/time field in access has probably

> > "required" set to "yes" - set it

> > to "no" instead to allow no dates to be inserted.

> >

> > -Kim

> >

> >

> > -----Original Message-----

> > From: dont worry [mailto:aspmailbox@y...]

> > Sent: 28. november 2001 00:17

> > To: ASP Databases

> > Subject: [asp_databases] insert date into access

> >

> >

> > I have date/time field in access, I get insert

> error

> > if I leave date blank.  I have to enter

> > #my/date/here#

> > or I get error.  How do I avoid this error?

> > Thanks

> >

> >

> >



> > aspmailbox@y...


> > $subst('Email.Unsub')

> >

> > Read the future with ebooks at B&N

> >

>

http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&catego

ryid=rn_ebooks

>

>

> __________________________________________________

> Do You Yahoo!?

> Yahoo! GeoCities - quick and easy web site hosting,

> just $8.95/month.

> http://geocities.yahoo.com/ps/info1

>

>



> aspmailbox@y...


> $subst('Email.Unsub')

>

> Read the future with ebooks at B&N

>

http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&catego

ryid=rn_ebooks





__________________________________________________

Do You Yahoo!?

Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.

http://geocities.yahoo.com/ps/info1







philipsayers@m...


$subst('Email.Unsub')



Read the future with ebooks at B&N

http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&catego

ryid=rn_ebooks





Message #8 by dont worry <aspmailbox@y...> on Wed, 28 Nov 2001 14:03:02 -0800 (PST)
Philip,

That didn't work.  Kim its too much code, can you send

me a simple insert and database with date/time in it?



--- Philip Sayers <philipsayers@m...> wrote:

> Have you tried putting in the date delimiters but

> with nothing between

> them?  I see in your SQL below, you don't have

> delimiters on the missing

> date, but you have delimiters on the missing

> strings.

> 

> 

> -----Original Message-----

> From: dont worry [mailto:aspmailbox@y...]

> Sent: Wednesday, November 28, 2001 4:26 PM

> To: ASP Databases

> Subject: [asp_databases] RE: insert date into access

> 

> Kim and Tim

> Access 97,

> Required set to NO

> Default Value set to NULL

> Indexed Yes(Duplicates OK)

> I even put asp

> if dbDOB = "" Then

>    dbDOB = NULL

> end if

> and it still doesn't work?  I don't want to resort

> to

> putting a fake date?  What should I try?

> Thanks

> --- dont worry <aspmailbox@y...> wrote:

> > Kim,

> > It is set to no.  Here is the insert statement and

> > it

> > only gives error when BirthDate is missing.  Is

> > there

> > something I could enter?

> >

> > INSERT INTO MembersTable (UserID , Password ,

> > FirstName , LastName , Gender , DateofBirth,

> > EmailAddress , Address , City , Country , State ,

> > PostalCode , PrimaryPhone , SecondaryPhone,

> FaxPhone

> > ,

> > CreditCardNum , CreditCardExp, ProductAmount,

> > Occupation, CreatedDTM, ModifiedDTM, CreatedBy)

> > VALUES

> > ('t3', 'pass', 't3' ,'t3', 'female', , 't3@t...'

> ,

> > '

> > ' , '' , '' , '' , '' , '', '', '' , 545 ,

> > #2002/02/01# , 2.00 , '' , #11/28/2001#,

> > #11/28/2001#

> > , 'WebForm' )

> >

> > --- Kim Iwan Hansen <kimiwan@k...> wrote:

> > > your date/time field in access has probably

> > > "required" set to "yes" - set it

> > > to "no" instead to allow no dates to be

> inserted.

> > >

> > > -Kim

> > >

> > >

> > > -----Original Message-----

> > > From: dont worry [mailto:aspmailbox@y...]

> > > Sent: 28. november 2001 00:17

> > > To: ASP Databases

> > > Subject: [asp_databases] insert date into access

> > >

> > >

> > > I have date/time field in access, I get insert

> > error

> > > if I leave date blank.  I have to enter

> > > #my/date/here#

> > > or I get error.  How do I avoid this error?

> > > Thanks

> > >

> > >

> > >

> > > ---

> > > You are currently subscribed to asp_databases

> as:

> > > aspmailbox@y...


> > > $subst('Email.Unsub')

> > >

> > > Read the future with ebooks at B&N

> > >

> >

>

http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&catego

> ryid=rn_ebooks

> >

> >

> > __________________________________________________

> > Do You Yahoo!?

> > Yahoo! GeoCities - quick and easy web site

> hosting,

> > just $8.95/month.

> > http://geocities.yahoo.com/ps/info1

> >

> >



> > aspmailbox@y...


> > $subst('Email.Unsub')

> >

> > Read the future with ebooks at B&N

> >

>

http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&catego

> ryid=rn_ebooks

> 

> 

> __________________________________________________

> Do You Yahoo!?

> Yahoo! GeoCities - quick and easy web site hosting,

> just $8.95/month.

> http://geocities.yahoo.com/ps/info1

> 

> 



> philipsayers@m...


> $subst('Email.Unsub')

> 

> Read the future with ebooks at B&N

>

http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&catego

> ryid=rn_ebooks

> 

> 

> 

>  



> aspmailbox@y...


> $subst('Email.Unsub')

> 

> Read the future with ebooks at B&N

>

http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&categoryid=rn_ebooks





__________________________________________________

Do You Yahoo!?

Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.

http://geocities.yahoo.com/ps/info1

Message #9 by "Ken Schaefer" <ken@a...> on Thu, 29 Nov 2001 12:44:28 +1100
Check to see if the user submitted a valid date using isDate()

If the date is not valid, or is missing, then insert a NULL value instead of

the user supplied date.

Ensure that your database allows NULLs for this column



If you don't want to allow NULLs, then you're going to have to abort the

insert and present an error message to the user instead.



Cheers

Ken



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From: "dont worry" <aspmailbox@y...>

Subject: [asp_databases] RE: insert date into access





: Philip,

: That didn't work.  Kim its too much code, can you send

: me a simple insert and database with date/time in it?



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Message #10 by dont worry <aspmailbox@y...> on Thu, 29 Nov 2001 08:08:25 -0800 (PST)
Ken,

Here is the update.

Access 97,

Required set to no

Default value set to NULL



If date is entered I have no problem, its when it is

blank that I get a problem.  I tried, 

if dob="" then

  dob = NULL

end if

+++didn't work+++

tried ## in insert

+++didn't work+++

Here is code insert.

sqlAdd = " INSERT INTO MembersTable " & _

						 " (UserID , Password , FirstName , LastName ,

Gender , DateofBirth, EmailAddress , Address , City ,

Country , State , PostalCode , PrimaryPhone ,

SecondaryPhone, FaxPhone , CreditCardNum ,

CreditCardExp, ProductAmount, Occupation, CreatedDTM,

ModifiedDTM, CreatedBy) " & _

						 "	VALUES ('"&x_Cust_ID&"', '" &x_Password& "',

'" &x_First_Name& "' ,'" &x_Last_Name& "', '"

&x_Gender& "',"&x_BirthDTM&", '" &x_Email& "' , '"

&x_Address& "' , '" &x_City& "' , '" &x_Country& "' ,

'" &x_State& "' , '" &x_Zip& "' , '" &x_Phone& "', '"

&x_SecPhone& "', '" &x_Fax& "' , " &x_Card_Num& " ,

"&x_Exp_Date&" , " &x_Amount& " , '" &x_Occupation& "'

, #" &Date()& "#, #" &Date()& "# , 'WebForm' ) "		

++++++below is response.write of sql string

INSERT INTO MembersTable (UserID , Password ,

FirstName , LastName , Gender , DateofBirth,

EmailAddress , Address , City , Country , State ,

PostalCode , PrimaryPhone , SecondaryPhone, FaxPhone ,

CreditCardNum , CreditCardExp, ProductAmount,

Occupation, CreatedDTM, ModifiedDTM, CreatedBy) VALUES

('t6', 'pass', 't6' ,'t6', 'female',, 't6@6...' , ' '

, '' , '' , '' , '' , '', '', '' , 54 , #2002/02/01# ,

5 , '' , #11/29/2001#, #11/29/2001# , 'WebForm' ) 

Microsoft OLE DB Provider for ODBC Drivers error

'80040e14' 



[Microsoft][ODBC Microsoft Access Driver] Syntax error

in INSERT INTO statement







--- Ken Schaefer <ken@a...> wrote:

> Check to see if the user submitted a valid date

> using isDate()

> If the date is not valid, or is missing, then insert

> a NULL value instead of

> the user supplied date.

> Ensure that your database allows NULLs for this

> column

> 

> If you don't want to allow NULLs, then you're going

> to have to abort the

> insert and present an error message to the user

> instead.

> 

> Cheers

> Ken

> 

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> From: "dont worry" <aspmailbox@y...>

> Subject: [asp_databases] RE: insert date into access

> 

> 

> : Philip,

> : That didn't work.  Kim its too much code, can you

> send

> : me a simple insert and database with date/time in

> it?

> 

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> 

> 

>  



> aspmailbox@y...


> $subst('Email.Unsub')

> 

> Read the future with ebooks at B&N

>

http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&categoryid=rn_ebooks





__________________________________________________

Do You Yahoo!?

Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.

http://geocities.yahoo.com/ps/info1

Message #11 by "Ken Schaefer" <ken@a...> on Fri, 30 Nov 2001 12:25:06 +1100
No, you don't want to assign a VBScript NULL value to your variable. You

want to assign a string containing the word "NULL" to your variable, and

then this will be passed in your SQL statement.



<%

dteDate = Request.Form("txtDate")

If Len(dteDate) > 0 and isDate(dteDate) then

    dteDate = "#" & dteDate & "#"

Else

    dteDate = "NULL"

End If



strSQL = _

    "INSERT INTO table1 (" & _

    "datefieldhere)" & _

    "VALUES("  _

    "" & dteDate & ")"



Response.Write(strSQL)

%>



Suppose the user entered a valid date (1/1/1980), then we put #1/1/1980#

into the SQL string, otherwise we put "NULL" into the SQL string.



Cheers

Ken



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From: "dont worry" <aspmailbox@y...>

Subject: [asp_databases] RE: insert date into access





: Ken,

: Here is the update.

: Access 97,

: Required set to no

: Default value set to NULL

:

: If date is entered I have no problem, its when it is

: blank that I get a problem.  I tried,

: if dob="" then

:   dob = NULL

: end if



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Message #12 by dont worry <aspmailbox@y...> on Thu, 29 Nov 2001 18:11:40 -0800 (PST)
Ken,

1 - Thank you it worked

2 - What does the field have now? string, novalue?

3 - How did you know that?

4 - Thank you

--- Ken Schaefer <ken@a...> wrote:

> No, you don't want to assign a VBScript NULL value

> to your variable. You

> want to assign a string containing the word "NULL"

> to your variable, and

> then this will be passed in your SQL statement.

> 

> <%

> dteDate = Request.Form("txtDate")

> If Len(dteDate) > 0 and isDate(dteDate) then

>     dteDate = "#" & dteDate & "#"

> Else

>     dteDate = "NULL"

> End If

> 

> strSQL = _

>     "INSERT INTO table1 (" & _

>     "datefieldhere)" & _

>     "VALUES("  _

>     "" & dteDate & ")"

> 

> Response.Write(strSQL)

> %>

> 

> Suppose the user entered a valid date (1/1/1980),

> then we put #1/1/1980#

> into the SQL string, otherwise we put "NULL" into

> the SQL string.

> 

> Cheers

> Ken

> 

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> From: "dont worry" <aspmailbox@y...>

> Subject: [asp_databases] RE: insert date into access

> 

> 

> : Ken,

> : Here is the update.

> : Access 97,

> : Required set to no

> : Default value set to NULL

> :

> : If date is entered I have no problem, its when it

> is

> : blank that I get a problem.  I tried,

> : if dob="" then

> :   dob = NULL

> : end if

> 

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> 

> 

>  



> aspmailbox@y...


> $subst('Email.Unsub')

> 

> Read the future with ebooks at B&N

>

http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&categoryid=rn_ebooks





__________________________________________________

Do You Yahoo!?

Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.

http://geocities.yahoo.com/ps/info1

Message #13 by "Ken Schaefer" <ken@a...> on Fri, 30 Nov 2001 13:25:02 +1100
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From: "dont worry" <aspmailbox@y...>

Subject: [asp_databases] RE: insert date into access





: Ken,

: 1 - Thank you it worked

: 2 - What does the field have now? string, novalue?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



All you are doing is building a *string* (which happens to be an SQL

statement), and sending the SQL statement to the database for processing. If

the user enters a valid date you want to send:



INSERT INTO table1 (field1) VALUES (#1/1/1980#)



If the user did not enter a valid value, or left the field blank, you want

to send:



INSERT INTO table1 (field1) VALUES (NULL)



So, you just write your VBScript logic so that the string is built

correctly, then you send the string to the database using objConn.Execute

strSQL



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

: 3 - How did you know that?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



It's just logical - it helps if you write these things out onto a bit of

paper before you start writing your code...otherwise you get bogged down

very quickly.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

: 4 - Thank you

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



No problems



Cheers

Ken



Message #14 by dont worry <aspmailbox@y...> on Fri, 30 Nov 2001 07:02:44 -0800 (PST)
Ken,

I think my confusion was in the following.

I create the valid date as follows

dob= "#" &datehere& "#"

so I have dob = #7/24/1975#

When left blank 

I needed to build 

dob = "NULL"

The confusion was in the ## and ""

I kept think I had to pass it something with ## or

nothing at all, I didn't know it needed the ""



Make sense?

Thanks anyways,

DW



--- Ken Schaefer <ken@a...> wrote:

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> From: "dont worry" <aspmailbox@y...>

> Subject: [asp_databases] RE: insert date into access

> 

> 

> : Ken,

> : 1 - Thank you it worked

> : 2 - What does the field have now? string, novalue?

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> 

> All you are doing is building a *string* (which

> happens to be an SQL

> statement), and sending the SQL statement to the

> database for processing. If

> the user enters a valid date you want to send:

> 

> INSERT INTO table1 (field1) VALUES (#1/1/1980#)

> 

> If the user did not enter a valid value, or left the

> field blank, you want

> to send:

> 

> INSERT INTO table1 (field1) VALUES (NULL)

> 

> So, you just write your VBScript logic so that the

> string is built

> correctly, then you send the string to the database

> using objConn.Execute

> strSQL

> 

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> : 3 - How did you know that?

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> 

> It's just logical - it helps if you write these

> things out onto a bit of

> paper before you start writing your code...otherwise

> you get bogged down

> very quickly.

> 

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> : 4 - Thank you

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> 

> No problems

> 

> Cheers

> Ken

> 

> 

>  



> aspmailbox@y...


> $subst('Email.Unsub')

> 

> Read the future with ebooks at B&N

>

http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&categoryid=rn_ebooks





__________________________________________________

Do You Yahoo!?

Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.

http://geocities.yahoo.com/ps/info1


  Return to Index