Results 1 to 3 of 3

Thread: SQL Server 6.5 datetime datatype and VB Strings

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    18

    Angry

    I got a problem, i am using VB 6 to write a DB app and it connects to a SQL server 6.5, in the database two fields, TimeLogged and DateLogged are both datetime datatypes. In VB my date and times to add to the database are both strings.

    How can i get SQL server 6.5 to add them to the record( by converting them to datatime????) Please Help

  2. #2
    Addicted Member
    Join Date
    Sep 1999
    Location
    Philippines
    Posts
    196
    Check out the CONVERT function in SQL server 6.5. it goes like this...

    CONVERT(datetime, @yourdatestring, 101)

    If you just put 'MM/DD/YYYY', then the function will automatically set the time to 00:00:00.

    Anyway, just check it out.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    18
    This it the sql statment
    sqlTemp = "INSERT INTO tCallLog (IndexNumber, LoggedBy, ForConsultant, Client, Person, Timelogged, DateLogged, Notes, Urgent, Priority, WasRespondedTo) VALUES ( MAX('IndexNumber') + 1, '" & CurrentUser.username & "', '" & cmbConsultant.Text & "', '" & txtClient.Text & "', '" & txtPerson.Text & "', '" & txtTimeLogged.Text & "', '" & Format(Now, "dd/mm/yyyy") & "' , '" & Chr(35) & txtNotes.Text & Chr(35) & "', " & chkUrgent.Value & ", '" & cmbPriority.ListIndex & "', " & chkWasRespondedTo.Value & " );"

    ok ... table:
    IndexNumber int
    LoggedBy char
    ForConsultant char
    Client varchar
    Person varchar
    TimeLogged text
    DateLogged text
    Notes text (in vb multiline textbox)
    Urgent int
    Priority int
    WasRespondedTo int

    please help the error i keep getting is:
    "Implicit Conversion from datatype 'varchar' to 'int' is not allowed. Use the CONVERT function to run this query."

    but i cant find what is causing the error!

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