Problem with Datagrid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • venkatanarasimhaa
    New Member
    • Dec 2007
    • 20

    Problem with Datagrid

    Hi,

    My Query is "SELECT * FROM table WHERE Acc_no like '1*' "

    If I run this query in Ms-Access directly, it is working fine.

    but if i try to show the same result in the datagrid, it is not showing any results.

    My code is :
    strsql = "SELECT * FROM table WHERE Acc_no like '1*' "
    Set rs = Login.conn.Exec ute(strsql)
    Adodc1.RecordSo urce = strsql
    Adodc1.Refresh

    If I give the same like below, It is working fine.
    strsql = "SELECT * FROM table WHERE Acc_no = '1' "
    Set rs = Login.conn.Exec ute(strsql)
    Adodc1.RecordSo urce = strsql
    Adodc1.Refresh


    Could you help me out in this?
    Thanks in advance.

    Regards,

    Venkat.
  • jamesd0142
    Contributor
    • Sep 2007
    • 471

    #2
    Originally posted by venkatanarasimh aa
    Hi,

    My Query is "SELECT * FROM table WHERE Acc_no like '1*' "

    If I run this query in Ms-Access directly, it is working fine.

    but if i try to show the same result in the datagrid, it is not showing any results.

    My code is :
    strsql = "SELECT * FROM table WHERE Acc_no like '1*' "
    Set rs = Login.conn.Exec ute(strsql)
    Adodc1.RecordSo urce = strsql
    Adodc1.Refresh

    If I give the same like below, It is working fine.
    strsql = "SELECT * FROM table WHERE Acc_no = '1' "
    Set rs = Login.conn.Exec ute(strsql)
    Adodc1.RecordSo urce = strsql
    Adodc1.Refresh


    Could you help me out in this?
    Thanks in advance.

    Regards,

    Venkat.
    you have to play around with query's in vb try using:


    [code=vbnet]
    strsql = "SELECT * FROM table WHERE Acc_no like " & "'" & "1%" & "'"
    [/code]

    its the ' thats throwing it out u see

    Comment

    • lotus18
      Contributor
      • Nov 2007
      • 865

      #3
      It is unnecessary to enclosed ' if the acc_no is a number type (access),

      Rey Sean

      Comment

      Working...