Results 1 to 5 of 5

Thread: Declaring data types in vbscript

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    North East (UK)
    Posts
    204

    Question Declaring data types in vbscript

    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

  2. #2
    chenko
    Guest
    Simple.......You don't

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    North East (UK)
    Posts
    204
    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

  4. #4
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    try

    sSQL="INSERT INTO IT_Requests (User_Name, IT_Requirement, Department, Location, Required_Date, Required_Time) VALUES ('" & from & "','" & department & "','" & location & "','" & description & "','" & date" & "','" & time & "') "

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    North East (UK)
    Posts
    204
    Cheers sebs, that worked fine. thought I had already tried that. Must have screwed my code up somewhere.

    Thanks again

    Colin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width