Re: FN-FORUM SQL Server INSERT (easy question)
date posted 10th July 2001 14:06
i rarely directly use inserts (i find sprocs more manageable), but i'll
stick a couple of ideas in...
firstly check which language/region the sql server is using as default and
set the session.lcid value to the relevant region which is 2057 for uk
english - look at
http://msdn.microsoft.com/scripting/default.htm?/scripting/vbscript/doc/vsms
cLCID.htm for other regions. this'll stop silly dates like the 7th day of
the 30th month creeping in
secondly i wouldn't use vblongdate as imo its suitable for outputting
date/times, but takes up space when inputting, also check dates with
isDate() and if your building the dates up from dropdowns use cdate().
finally if all else fails use a sproc - i've had datetime hassles before
using direct inserts, but never via a sproc, plus i find it makes the code
more readable! :)
hth
dave ecky
----- Original Message -----
From: "Norman Beresford" [EMAIL REMOVED]
To: [EMAIL REMOVED]
Sent: Tuesday, July 10, 2001 1:09 PM
Subject: Re: FN-FORUM SQL Server INSERT (easy question)
> Hi Peter
>
> Just tried that and it's not working :(
>
> Server: Msg 241, Level 16, State 1, Line 1
> Syntax error converting datetime from character string.
>
> Norman
>
>
> ----- Original Message -----
> From: "Peter Ebdon" [EMAIL REMOVED]
> To: [EMAIL REMOVED]
> Sent: Tuesday, July 10, 2001 12:35 PM
> Subject: RE: FN-FORUM SQL Server INSERT (easy question)
>
>
> > Norman,
> >
> > Try using a datetime data type for the table column instead.
> >
> > Cheers,
> >
> > Pete
> >
> > _________________________________________
> >
> > P e t e r E b d o n
> > Professional Software Engineering Ltd
> >
> > Microsoft Certified Professional
> >
> > Email : [EMAIL REMOVED]
> > Tel/Fax : +44(0)1235-227279
> > Mobile : +44(0)7973-178945
> > Web : www.pseltd.com
> >
> > -----Original Message-----
> > From: [EMAIL REMOVED]
> > [EMAIL REMOVED] Behalf Of Norman Beresford
> > Sent: 10 July 2001 11:38
> > To: [EMAIL REMOVED]
> > Subject: Re: FN-FORUM SQL Server INSERT (easy question)
> >
> > Hi Carl
> >
> > Thanks for that, the real problem I'm having is with the time though
> > I've converted the the dates as you suggested, but it's now giving me
an
> > error with the time. I've attached the SQL, the ASP and the error
message
> > at the end of this.
> >
> > Norman
> >
> > SQL
> >
> > INSERT INTO motivaction ( motiveTitle, motiveForename, motiveSurname,
> > motiveOrganisation, motiveAddress, motivePostcode, motiveTelephone,
> > motiveEmail, motiveContactMethod, motiveDate, motiveStart, motiveFinish,
> > motiveVenue, motiveGuests, motivePackageID, motiveDateBooked)
> > VALUES ('Miss', 'Belinda', 'Beresford', 'Private Individual', '105
Houblon
> > RoadRichmondSurrey', 'TW10 6DB', '020 8241 2222,
> > [EMAIL REMOVED] 'Email', 'Tuesday, September 10, 2002',
> '21:00',
> > '23:30', 'Back garden', 68, 11, 'Tuesday, July 10, 2001');
> >
> > ASP
> >
> > thisSQL = _
> > "INSERT INTO motivaction ( motiveTitle, motiveForename, motiveSurname,
> > motiveOrganisation, motiveAddress, motivePostcode, motiveTelephone,
> > motiveEmail, motiveContactMethod, motiveDate, motiveStart, motiveFinish,
> > motiveVenue, motiveGuests, motivePackageID, motiveDateBooked)" & _
> > " VALUES ('" & bookingTitle & "', '" & bookingForename & "', '" &
> > bookingSurname & "', '" & bookingOrg & "', '" & bookingAddress & "', '"
&
> > bookingPostCode & "', '" & bookingTelephone & "', '" & bookingEmail &
"',
> '"
> > & bookingContactMethod & "', '" & formatdatetime(bookingDate,vbLongDate)
&
> > "', '" & formatdatetime(bookingTimeStart,VBShortTime) & "', '" &
> > formatdatetime(bookingTimeFinish,VBShortTime) & "', '" & bookingVenue &
> "',
> > " & bookingNumbers & ", " & packageID & ", '" &
> > formatdatetime(bookingDateBooked,vbLongDate) & "');"
> >
> > Error message
> >
> > Server: Msg 295, Level 16, State 3, Line 1
> > Syntax error converting character string to smalldatetime data type.
> >
> >
> >
> > ============================================================
> >
> > * Free listing for freelancers
> > * Free to advertise jobs
> > * Free jobs distribution service
> > * Free database of 1000 freelancers
> >
> > Freelancers and Freelance Jobs
> > http://www.freelancers.net
> >
> > To post to the Forum:
> > [EMAIL REMOVED]
> >
> > To unsubscribe please email:
> > [EMAIL REMOVED]
> >
> > If you have difficulties unsubscribing please email:
> > [EMAIL REMOVED]
> >
> > To subscribe to the digest for this list or for further information
please
> > visit:
> > http://www.freelancers.net/forum.html
> >
> >
> >
> > ============================================================
> >
> > * Free listing for freelancers
> > * Free to advertise jobs
> > * Free jobs distribution service
> > * Free database of 1000 freelancers
> >
> > Freelancers and Freelance Jobs
> > http://www.freelancers.net
> >
> > To post to the Forum:
> > [EMAIL REMOVED]
> >
> > To unsubscribe please email:
> > [EMAIL REMOVED]
> >
> > If you have difficulties unsubscribing please email:
> > [EMAIL REMOVED]
> >
> > To subscribe to the digest for this list or for further information
please
> visit:
> > http://www.freelancers.net/forum.html
> >
>
>
>
> ============================================================
>
> * Free listing for freelancers
> * Free to advertise jobs
> * Free jobs distribution service
> * Free database of 1000 freelancers
>
> Freelancers and Freelance Jobs
> http://www.freelancers.net
>
> To post to the Forum:
> [EMAIL REMOVED]
>
> To unsubscribe please email:
> [EMAIL REMOVED]
>
> If you have difficulties unsubscribing please email:
> [EMAIL REMOVED]
>
> To subscribe to the digest for this list or for further information please
visit:
> http://www.freelancers.net/forum.html