vbnet Parametrised SQL

Private Sub LookupURL()
	Dim conn As New SqlConnection(My.Settings.slickurls)
	Dim cmd As SqlCommand = New SqlCommand()
	Dim dr As SqlDataReader

	With cmd
		.CommandText = "Select Top 1 [Url] From Urls Where UrlKey = @UrlKey Order By DateAdded Desc" 'selects latest Url as duplicates may be present
		.CommandType = CommandType.Text
		.Parameters.AddWithValue("@UrlKey", UrlKey)
		.Connection = conn
		dr = .ExecuteReader()
	End With

	While dr.Read
		Url = dr("Url").ToString
	End While


	With cmd
	End With
End Sub
Parametrised SQL - as used on slck.it

Updated: Saturday 9th October 2010, 08:01pm

There are 0 comments

Leave a comment of your own

Comments are currently closed.