Beispiel #1
0
 //插入操作
 public int InsertSearch(SearchEntity t_Search)
 {
     //定义插入数据的参数数组
       OleDbParameter[] p=new OleDbParameter[]{
       new OleDbParameter("@Search_id",t_Search.Search_id),
       new OleDbParameter("@User_id",t_Search.User_id),
       new OleDbParameter("@Search_text",t_Search.Search_text)
        };
        int i=OLEDBHelp.GetExecute("insert into Search values (@Search_id,@User_id,@Search_text)", p) ;
        return i;
 }
Beispiel #2
0
 //根据外键进行查询
 public IList<SearchEntity> GetAllSearchByuser_id(int t_user_id)
 {
     IList<SearchEntity> t_Searchs = new List<SearchEntity>();
        OleDbDataReader sdr = null;
        using(sdr=OLEDBHelp.GetReader("select * from Search where user_id="+t_user_id))
        {
       while(sdr.Read())
         {
             SearchEntity t_Search= new SearchEntity();
             t_Search.Search_id=(int)sdr.GetValue(0);
             t_Search.User_id=(int)sdr.GetValue(1);
             t_Search.Search_text=(string)sdr.GetValue(2);
             t_Searchs.Add(t_Search);
         }
         sdr.Close();
     }
     return t_Searchs;
 }
Beispiel #3
0
 //根据主键查询整个表
 public IList<SearchEntity> GetAllSearch()
 {
     IList<SearchEntity> t_Searchs = new List<SearchEntity>();
     SqlDataReader sdr = null;
     using(sdr=SqlDBHelp.GetReader("select * from Search"))
     {
         while(sdr.Read())
         {
             SearchEntity t_Search= new SearchEntity();
             t_Search.Search_id=(int)sdr.GetValue(0);
             t_Search.User_id=(int)sdr.GetValue(1);
             t_Search.Search_text=(string)sdr.GetValue(2);
             t_Searchs.Add(t_Search);
         }
         sdr.Close();
     }
     return t_Searchs;
 }
Beispiel #4
0
 public SearchEntity SelectSearchByID(int t_search_id)
 {
     SearchEntity t_Search= new SearchEntity();
     OleDbDataReader sdr=null;
     using(sdr=OLEDBHelp.GetReader("select * from Search where search_id="+t_search_id))
     {
         if(sdr.Read())
         {
             t_Search.Search_id=(int)sdr.GetValue(0);
             t_Search.User_id=(int)sdr.GetValue(1);
             t_Search.Search_text=(string)sdr.GetValue(2);
         }
     }
     sdr.Close();
     return t_Search;
 }
Beispiel #5
0
 public int UpdateSearch(SearchEntity t_Search)
 {
     OleDbParameter[] p=new OleDbParameter[]{
     new OleDbParameter("@Search_id",t_Search.Search_id),
     new OleDbParameter("@User_id",t_Search.User_id),
     new OleDbParameter("@Search_text",t_Search.Search_text)
     };
     int i=OLEDBHelp.GetExecute("update Search set search_id=@Search_id,search_text=@Search_text where search_id=@Search_id", p) ;
     return i;
 }
Beispiel #6
0
 //插入操作
 public static int InsertSearch(SearchEntity t_Search)
 {
     int i=-1;
     //定义插入数据的参数数组
     try
     {
         i=dal.InsertSearch(t_Search);
     }
     catch(Exception ex)
     {
         throw new Exception(ex.Message);
     }
        return i;
 }