Forums

ASP

This topic is locked

why doesnt this work

Posted 16 Oct 2003 19:29:23
1
has voted
16 Oct 2003 19:29:23 Brian Pregelr posted:
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection" )
objConn.Open ("Driver={SQL Server};Server=myserver;Database=mydb; UID=Id;PWD=pd"
objConn.Execute
"insert into clicks (url, date_clicked) values ('"& Request("url" &"' , '"& GETDATE()&"')"
objconn.Close
Set objconn = Nothing
please help thanks. bp

Replies

Replied 17 Oct 2003 22:15:13
17 Oct 2003 22:15:13 Marcellino Bommezijn replied:
What is the error it returns when you run the page with the code?
Replied 20 Oct 2003 16:14:25
20 Oct 2003 16:14:25 Brian Pregelr replied:
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'GETDATE'
/clicks.asp, line 38
Where line 38 is:
"insert into clicks (url, date_clicked) values ('"& Request("url" &"' , '"& GETDATE()&"')"
Replied 21 Oct 2003 12:09:18
21 Oct 2003 12:09:18 Stuart Harland replied:
You problem is that 'GETDATE()' is not an ASP function (which you are trying to call) it is a SQL Funtion. So you should just be writing your SQL string like so:

<pre id=code><font face=courier size=2 id=code>insert into clicks (url, date_clicked) values ('"& Request("url" &"' , GETDATE())"
</font id=code></pre id=code>

This means that SQL Server will run the function on the insert. Another, easier method would be to place 'GetDate()' as the default value of the 'date_clicked' field in your SQL Table. This means you don't have to touch that field...SQL handles it for you. Also make sure your field is a Datetime data type.

********************
Stuart - Ferox
Web Applications Developer
ASP.Net/ ASP

Edited by - Ferox101 on 21 Oct 2003 12:10:11

Reply to this topic