Results 1 to 5 of 5

Thread: VB and SQL Server

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    18

    Angry

    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!


  2. #2
    Lively Member
    Join Date
    Jun 2000
    Posts
    80

    text instead of a INT

    One of the fields* you are trying to insert is a text instead of a INT

    *
    IndexNumber int
    Urgent int
    Priority int
    WasRespondedTo int

    Good luck,

    Fedor

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    18
    I know about the int fields and the text is being passed to sql at explicit not as strings. i have used the same type of passing variables in other sql queries and it worked. I think it has something to do with the date and time.

    Thankx for the help.

  4. #4
    Addicted Member
    Join Date
    Jul 1999
    Location
    St-Élie d'Orford, Quebec, Canada
    Posts
    133
    I think it's "Priority" because it's an INT and you have INSERTED it with ' '. If you want to insert the listindex, don't use the ' '... and it will work fine I hope !!!

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    18
    Thankx Man, that looks like the problem. Sometimes it just helps to have someone else look at it.

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