Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Posts
    5

    Unhappy Unanswered: type mismatch error 13 from a query from VB

    I use mssql2000 and try to connect DB by
    dim cnn As ADODB.Connection
    dim rec As Recordset

    Set cnn = New ADODB.Connection
    cnn.Open "Provider=SQLOLEDB;Password=123if;User ID=sa;Initial Catalog=CustomerService;Data Source=SIAM-INT-SERV"

    ....the databse and connection is success and without error
    but after then i wanna query by

    Set rec = cnn.Execute("SELECT UsrNme, Passwd ,permission FROM Username where UsrNme = 'rud'")

    A runtime error 13, "Type Mismatch" is generated from the recordset creation query. I can use this code in win2000 but it's error 13 "type mismatch" in win98 ?????????I kinda confuse now...please help

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    is it something daft like the missing ; at the end?

    as in
    Set rec = cnn.Execute("SELECT UsrNme, Passwd ,permission FROM Username where UsrNme = 'rud';")

    i'm assuming >>rud<< is a literal string, else if it's a var you would need:
    where UsrNme = '" & rud & "';")

    otherwise it looks fine to me but then - i'm still at SQL 101

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Jan 2004
    Posts
    5
    actually my code is this..
    Public strConnect As String
    Public Source As String
    Public usr As String
    Public password As String
    Public initialc As String
    Public Strsql As String
    Public cnn As ADODB.Connection
    Public rec As Recordset 'for show data in grid


    Source = "SIAM-INT-SERV" 'SQL server host
    usr = "sa" 'user name
    password = "monkey52" 'password if applicable
    initialc = "CustomerService"
    strConnect = "Provider=SQLOLEDB;Password=" & password & ";User ID=" & usr & ";Initial Catalog=" & initialc & ";Data Source=" & Source & ""

    Set cnn = New ADODB.Connection
    cnn.Open strConnect
    Strsql = "SELECT UsrNme, Passwd ,permission FROM Username where UsrNme = '" & txtUserName.Text & "'"
    Set rec = cnn.Execute(Strsql)

    but i don't know about ';'
    I will try to add ';' again
    thank you for your help :>

  4. #4
    Join Date
    Jan 2004
    Posts
    5

    Red face

    i did try what you told me but.... the problem still be the same :< i'm trying to figure it out

Posting Permissions

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