473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem with inserting date value into MSSQL

I'm trying to insert a date value into MSSQL, the type of the sql filed
is: "smalldatetime"
and i'm trying to insert a text Variable that looks like this:
"19/02/2006".

.... SET update_date='" & Update_Date & "' ...

i get the message:

The conversion of char data type to smalldatetime data type resulted in
an out-of-range smalldatetime value

Nov 19 '06 #1
2 2520
Igal wrote:
I'm trying to insert a date value into MSSQL, the type of the sql
filed is: "smalldatetime"
and i'm trying to insert a text Variable that looks like this:
"19/02/2006".

... SET update_date='" & Update_Date & "' ...

i get the message:

The conversion of char data type to smalldatetime data type resulted
in an out-of-range smalldatetime value
Always use a universally standard format for supplying dates to a database.
The ISO standard, YYYYMMDD works very well. Here are a couple articles about
handling dates:
http://www.aspfaq.com/show.asp?id=2313
http://www.aspfaq.com/show.asp?id=2040
http://www.aspfaq.com/show.asp?id=2260
Further points to consider:
Your use of dynamic sql is leaving you vulnerable to hackers using sql
injection:
http://mvp.unixwiz.net/techtips/sql-injection.html
http://www.sqlsecurity.com/DesktopDefault.aspx?tabid=23

See here for a better, more secure way to execute your queries by using
parameter markers:
http://groups-beta.google.com/group/...e36562fee7804e

Personally, I prefer using stored procedures.
http://groups.google.com/group/micro...9dc1701?hl=en&

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Nov 19 '06 #2
in the end i used a functions that converts the date to SQL format
(YYYY/MM/DD)
and that worked fine.
but for this application nothing much u can do, it's very old code, and
i'm trying some how to polish, i'm php programmer, not asp actually :)
will prolly write a new one in time for the whole system.

this article is very interesting and helpful. thanks for the
information.
http://mvp.unixwiz.net/techtips/sql-injection.html
Nov 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: J. Muenchbourg | last post by:
while inserting new records into SQL, i'm using the folloinwg sqlstatement> Dim MySQL as string = "Insert into roster (pname, pnotes, thedate) values (@pname, @pnotes, @thedate)" the sql...
4
by: Bradley Burton | last post by:
I'm using Allen Brown's code for audit logging (http://allenbrowne.com/AppAudit.html), but I'm having a problem. My aud table doesn't populate with the tracking info at all. I think it might be a...
1
by: Ugur Ekinci | last post by:
Hi , I have two Sql Server 2000 on seperate machines , First one accepts datetime format like ("dd.MM.yyyy hh:mm:ss") And Second one accepts datetime format like ("MM.dd.yyyy hh:mm:ss") 1-...
3
by: Rajani | last post by:
Hello, I replaced the calendar control to 3 dropdownlists(day,month and year) coz i want to display the calendar as just like DTPicker in vb.6. But i cant able to display like that. The form...
11
by: iulian.ilea | last post by:
Hello, I store a date ( format mm/dd/yyyy ) on MsSQL in a datetime field. In DB is stored correctly, same format, but when I retrieve it I get dd/mm/yyyy. You have any ideea why this is...
2
Spazasaurus
by: Spazasaurus | last post by:
I am having trouble. I am not sure if it is not possible or not, but don't know any alternatives. I am converting my site from PHP and MYSQL to ASP.NET and MSSQL. In my current site. I did a query...
3
by: Robert Johnson | last post by:
Hi all. Created a simple table in my db. 3 colums one is a Int set for autoincrement. Itentity True, seed 1, Incremement 1, null False. The other colums are simple VarChar(50) null false on the...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
58
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.