Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   sql connectivity (http://www.go4expert.com/forums/sql-connectivity-t3081/)

kishgan 20Feb2007 17:11

sql connectivity
 
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.

ever_thus 27Feb2007 22:36

Re: sql connectivity
 
Code:

Dim TableSource As String
' Tablename from which records are taken
Dim SearchField As String
' Field used in the "Where" clause
Dim SearchString As String
' Matching string used in the "Where" clause
Dim SearchValue As Integer
' For "Where" clause with numeric field.
'    (Type may be other than Integer)
Dim SortField As String
' Field for sorting alpahbetically
Dim SQL As String
' This is where we'll put the SQL string
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


All times are GMT +5.5. The time now is 14:10.