Private Sub SelectSQLSort (ByVal OrderByField As String)
Dim SQLString As String
SQLString = "SELECT fields FROM tables ORDER BY " & OrderByField
Add the variable SQLString to a datacommand, dataset select command or whatever your using - place that code here
End Sub
SelectSQLSort (field2)
CREATE PROCEDURE dbo.spAddressSelectFilter
(
@Address1 varchar(255) = NULL,
@Address2 varchar(255) = NULL,
@City varchar(255) = NULL,
@PostalCode varchar(255) = NULL,
@SessionToken uniqueidentifier = NULL
)
AS
SELECT *
FROM tblAddress
WHERE (( Address1 LIKE @Address1) OR (@Address1 IS NULL))AND
((Address2 LIKE @Address2)OR (@Address2 IS NULL))
((City LIKE @City) OR (@City IS NULL))AND
((PostalCode LIKE @PostalCode) OR (@PostalCode IS NULL))
SELECT *
FROM tblAddresses
WHERE Address1 LIKE COALESCE(@Address1,Address1) AND
Address2 LIKE COALESCE(@Address2,Address2)
City LIKE COALESCE(@City,City) AND
PostalCode LIKE COALESCE(@PostalCode, PostalCode)