The text of this article is not in this database — only its details are. Read it on the old site: Microsoft patterns & practices: The Enterprise Library in VB.NET
1 Comment
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
JosefPosted Jun 22, 2006, 9:45 PM
I'm a bit confused about two lines of code and what they exactly do. Your example; 1 Private db As Database = DatabaseFactory.CreateDatabase("NorthwindDB_SQL") 'Prepare the SQL query. 2 Private sqlCommand As String = "Select EmployeeID, LastName + FirstName Name From Employees" 3 Private dbCommandWrapper As DBCommandWrapper = db.GetSqlStringCommandWrapper(sqlCommand) 4 Private dataReader As IDataReader=Nothing 'NOTE: The EmployeeDE represents a Data Entity class and the EmployeeDECollection class represents the collection for instances of the EmployeeDE class. 5 Private employeeCollection As EmployeeDECollection = New EmployeeDECollection() Try 6 dataReader = db.ExecuteReader(dbCommandWrapper) Line 3 gets the sqlCommand for that database object by passing the sqlcommand object into the database method called db.GetSqlStringCommandWrapper Why then in line 6 when you execute the command do you need to pass in the command wrapper. Since it contains the SQLcommand string which was already asociated with the current database in line 3 it appears as if you are just repeating yourself. Either line 3 and line 5 both associate the query to run with the db object.