ASP.NET - How to read an SQL View into a sqlDataReader using a sqlCommand object
Posted on 2003-02-18
I have created a view in an MS SQL v7 DB and would like to databind the contents to a list on a webform.
The code below works fine for a StoredProcedure but I want to know how to do it for a view.
Can it be done with a sqlDataReader and an sqlCommand ?
SqlCommand1.CommandText = "vEmployees"
objReader = SqlCommand1.ExecuteReader()
lbxEmployees.DataTextField = "Name"
lbxEmployees.DataValueField = "ID"
lbxEmployees.DataSource = objReader