1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

sql connectivity

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

  1. kishgan

    kishgan New Member

    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

    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
    where Data1 is a Form or Report object

Share This Page