关于三层架构,数据访问层实现的一个问题
请问数据访问层这样一个类的函数如何实现: 
 1.函数执行一select语句若数据库连接或查询没出现问题,则将结果以DataSet形式返回,若产生错误则将错误信息返回. 
 我刚学C#,希望大家给些指点,最好带实例,谢谢了
------解决方案--------------------public DataSet OnlineUserList() 
         { 
             try 
             { 
                 StringBuilder strSql = new StringBuilder(); 
                 strSql.Append( "select [pCode],[pName],[loginIP]  "); 
                 strSql.Append( " FROM UserOnline  "); 
                 return DbHelperSQL.Query(strSql.ToString()); 
             } 
             catch (SystemException ex) 
             { 
                 throw new Exception(ex.Message); 
             } 
         }
------解决方案--------------------public DataSet ExecuteQuery(string stringQuery) 
 { 
 DataSet dataSet=new DataSet(); 
 try 
 { 
 连接数据库; 
 执行查询语句; 
 return dataSet; 
 }  
 catch(exception ex) 
 { 
 throw new Exception(ex.Message); 
 } 
 fianly 
 { 
 关闭连接; 
 } 
 } 
 希望对你有用,不要骂人啊!!
------解决方案--------------------public DataSet ExecuteQuery(string stringQuery) 
 { 
           try 
         { 
             SqlConnection conn = new SqlConnection( "Server=.;Database=master;Integrated Security=SSPI "); 
             SqlDataAdapter da = new SqlDataAdapter( "select *from love ", conn); 
             DataSet ds = new DataSet();            
             da.Fill(ds); 
             if (ds != null) 
             { 
                    this.dataGridView1.DataSource = ds.Tables[0]; 
             } 
         } 
         catch(Exception ex) 
        { 
               MessageBox.Show(ex.ToString()); 
         } 
 } 
------解决方案--------------------从基础学起