Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2003
    Posts
    21

    Unanswered: Recordset Problem

    I'm creating a Visual Basic program linked to an SQL server DB. In one of my tables I have a field for phone number which is an nvarchar datatype that is stored in the following format (example: 617-782-6415).

    I have a form where I want to view the contents of the following recordset:

    SELECT d .ACCOUNT_CODE, d .DURATION, d .[DATE], d .[HOUR], d .NUMBER_DIALED, p.ACCOUNT_CODE AS Expr1, p.LAST_NAME, p.FIRST_NAME,
    p.SUMMARY_GROUP, p.DIRECT_DIAL, p.TITLE, p.LOCATION, p.DIVISION, p.DEPARTMENT, p.DIRECTOR, p.OLD_CARD_NUM, p.REISSUE, p.CLASS,
    p.PHONE
    FROM DETAIL d INNER JOIN
    PHONE_EMP_MAST p ON d .ACCOUNT_CODE = p.ACCOUNT_CODE
    WHERE number_dialed = " & astring & "


    The value for astring is pulled from a combobox that stores all the values for number_dialed. However when i run this program i get the error message

    "syntax error converting the nvarchar value '401-781-7078' to a column of datatype int"

    I dont need to convert it to a column of datatype int so I dont understand this error... can anyone help me?

  2. #2
    Join Date
    Feb 2003
    Location
    Auckland, NZ
    Posts
    150

    Cool Re: Recordset Problem

    There are two things I will check.

    1.Check the INNER JOIN.
    Make sure that the JOINED FIELDS are of the same data type

    2. Chek your WHERE statement. Make sure you have single quotation around the text string as shown below.

    Dim MySQLStr as String

    MySQLStr = "SELECT Field1 FROM Table1 WHERE Field2 = '" & VAriable1 & "'"

Posting Permissions

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