sql connectivity

Discussion in 'Visual Basic ( VB )' started by kishgan, Feb 20, 2007.

  1. kishgan

    kishgan New Member

    Joined:
    Feb 20, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    i would like to know how i could use sql queries in my VB application.

    i would also like to know which query could be used to sort the values in alphabetical order.
     
  2. ever_thus

    ever_thus New Member

    Joined:
    Jan 3, 2007
    Messages:
    53
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    Dim TableSource As String[INDENT]' Tablename from which records are taken[/INDENT]Dim SearchField As String[INDENT]' Field used in the "Where" clause[/INDENT]Dim SearchString As String[INDENT]' Matching string used in the "Where" clause[/INDENT] Dim SearchValue As Integer[INDENT]' For "Where" clause with numeric field.[/INDENT][INDENT]'    (Type may be other than Integer)[/INDENT]Dim SortField As String[INDENT]' Field for sorting alpahbetically[/INDENT] Dim SQL As String[INDENT]' This is where we'll put the SQL string[/INDENT]
    
    SQL = "Select * from [" & TableSource & "]"
    SQL = SQL & " Where [" & SearchField & "] Like ""*" & SearchString & "*"""
    SQL = SQL & " Order by [" & SortField & "]"
    Data1.RecordSource = SQL
    Data1.Refresh
    where Data1 is a Form or Report object
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice