Click to See Complete Forum and Search --> : Declaring data types in vbscript
colin
Jul 10th, 2001, 09:03 AM
Hi all,
can anyone tell me how to declare the date datatype in vbscript, for example I want to be able to say;
dim mydate as date
I cannot find the syntax for this in vbscript.
Cheers,
Colin
chenko
Jul 10th, 2001, 09:04 AM
Simple.......You don't
colin
Jul 10th, 2001, 09:11 AM
A little more:
I have a script which is connecting to a SQL Server database but it dies when doing the "INSERT INTO" sql code with the error message:
Error: cannot convert string into a date datatype.
this is the code i am using:
Sub cmdSubmit_OnClick()
Dim from
Dim department
Dim Location
Dim description
Dim date
Dim time
Dim dBase
Dim sConn
Dim sSQL
from = txtFrom.value
department = txtDepartment.value
location = txtLocation.value
description = txtDescription.value
date = txtDate.value
time = txtTime.value
Set dBase=CreateObject("ADODB.Connection")
sConn="PROVIDER=SQLOLEDB;Data Source=CHIMERA;Initial Catalog=Forms_Data;uid=;pwd="
dBase.CursorLocation="3"
dBase.ConnectionTimeout=30
dBase.Open sConn
sSQL="INSERT INTO IT_Requests (User_Name, IT_Requirement, Department, Location, Required_Date, Required_Time) VALUES ('from','department','location','description','date','time') "
dBase.execute(sSQL)
dBase.close
Set dBase=nothing
End sub
-->
</SCRIPT>
Cheers
Colin
sebs
Jul 10th, 2001, 09:15 AM
try
sSQL="INSERT INTO IT_Requests (User_Name, IT_Requirement, Department, Location, Required_Date, Required_Time) VALUES ('" & from & "','" & department & "','" & location & "','" & description & "','" & date" & "','" & time & "') "
colin
Jul 10th, 2001, 09:24 AM
Cheers sebs, that worked fine. thought I had already tried that. Must have screwed my code up somewhere.
Thanks again
Colin
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.