In the alternative method ReadItem error code with the following code:
![Module6_video04_BCS_VS2010_36.png]()
	
	public
	
	static 
	ReadItem Customer
	(int id) 
	        { 
	
	            Customer 
	customer = new 
	Customer (); 
	
	            SqlConn = 
	GetSqlConnection SqlConnection (); 
	
	
	            sqlConn.Open 
	(); 
	
	           
	SqlCommand SqlCommand =
	new SqlCommand 
	(); 
	
	            
	sqlCommand.CommandText = 
	"select CustomerID, CustomerName, City" 
	
	
	                + 
	"From Customer"
	
	
	                +
	"WHERE CustomerID =" + id.ToString ();
	
	
	            
	sqlCommand.Connection = sqlConn; 
	
	           
	SqlDataReader SqlDataReader = 
	sqlCommand.ExecuteReader (CommandBehavior. 
	CloseConnection); 
	
	           
	if (sqlDataReader.Read ()) 
	
	
	            { 
	
	
	                
	customer.CustomerID = int. Parse (SqlDataReader 
	[0]. ToString ()); 
	
	                
	customer.CustomerName = SqlDataReader [1]. ToString (); 
	
	                
	Customer.City = SqlDataReader [2]. ToString (); 
	
	            } 
	
	
	            
	else
	
	            { 
	                customer.CustomerID = -1; 
	                customer.CustomerName = 
	"Customer Not Found"; 
	                Customer.City = 
	""; 
	            } 
	            sqlConn.Dispose (); 
	            return customer; 
	        } 
 
	In the method declaration code ReadList
![Module6_video04_BCS_VS2010_37.png]()
	
	/ / /
	
	
	<summary> 
	        / 
	/ / This is a sample 
	method for Entity1 finder.
	
	        / 
	/ / If You Want to 
	delete or rename the method to think about changing the xml file in the BDC 
	model as well. 
	        / 
	/ / 
	
	</ Summary> 
	        / 
	/ / 
	
	<returns>
	IEnumerable of Entities 
	</ returns>
	
	        public 
	static IEnumerable <Customer> 
	ReadList () 
	        {
	
	
	            SqlConnection 
	SqlConnection = GetSqlConnection ();
	
	
	            try
	
	
	            {
	
	
	                List 
	<Customer> allCustomers = new List 
	<Customer> (); 
	
	
	                sqlConnection.Open 
	(); 
	
	                SqlCommand 
	SqlCommand = new SqlCommand ();
	
	
	                sqlCommand.Connection 
	= SqlConnection; 
	
	
	                sqlCommand.CommandText 
	= "select CustomerID, 
	CustomerName, City from Customer";
	
	
	                SqlDataReader 
	SqlDataReader = sqlCommand.ExecuteReader (CommandBehavior. CloseConnection);
	
	
	                while 
	(sqlDataReader.Read ())
	
	
	                {
	
	
	                    Customer 
	customer = new Customer ();
	
	
	                    
	 customer.CustomerID 
	= int. Parse (SqlDataReader [0]. ToString 
	()); 
	
	                    customer.CustomerName 
	= SqlDataReader [1]. ToString ();
	
	
	                    Customer.City 
	= SqlDataReader [2]. ToString ();
	
	
	                    allCustomers.Add 
	(customer); 
	
	                
	 }
	
	
	                Customer 
	[] = new Customer customerList [allCustomers.Count];
	
	
	                for 
	(int customerCounter = 0; customerCounter <= allCustomers.Count - 1; 
	customerCounter + +)
	
	
	                {
	
	
	                    customerList 
	[customerCounter] = allCustomers [customerCounter];
	
	                }
	
	                return 
	(customerList); 
	            }
	
	            catch
	(Exception ex)
	
	            {
	
	                Tellme
	String = ex.Message;
	
	                Customer 
	[] customerlist = new Customer [0];
	
	                Customer 
	customer = new Customer ();
	
	                customer.CustomerID 
	= -1; 
	                customer.CustomerName 
	= "Unable to retrieve 
	data"; 
	
	                Customer.City 
	= "";
	
	                customerlist 
	[0] = customer; 
	                return 
	(customerlist); 
	            }
	
	            finally
	
	            {
	
	                sqlConnection.Dispose 
	(); 
	            }
	
	
	        }