Using Variables inside a Query

15 Sep

‘Define variables as input for our sql query

Dim sEmpId As Int32 = 1

Dim sHireDate As String = “1 January 1993”

Dim sCountry As String = “USA”
‘Populate Connection Object

Dim oCnn As New OleDbConnection(sCnnString)
‘Define our sql query

Dim sSQL As String = “SELECT FirstName, LastName, Title ” & _

“FROM Employees ” & _

“WHERE ((EmployeeID >” & sEmpId & ” AND HireDate >#” & _

sHireDate & “#) AND Country = ‘” & sCountry & “‘) ”


					
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: