Code:
strSql = "insert into table2 (transactiondate) values ('" & transactiondate & "')"
seems to give me a runtime error:
The conversion of a varchar data type to a smalldatetime data type resulted in an out-of-range value
In the code, strSql is a String object, and transactiondate is a Date object. However, in a SQL database, transactiondate is a smalldatetime object.
I tried changing smalldatetime to datetime (in the database) and I tried transactiondate.toString (), but without success.
How can this be fixed?
Note. I am aware of the dangers of embedded SQL. I am looking for a quick solution to the solution here, and not a discussion of SQL injection.
michael
source
share