传参数的方法!

   string sqlConnection2="Select JHBM,SPBM,KCSL,CGSL,CGJS,HSJJ,DDYZD from  SPCGJH_D where   JHBM=' "+WebTextEdit1.Text+" '  "; 
   SqlConnection connection = new SqlConnection(connString);
   cmdSPCGJH_D=new SqlDataAdapter(sqlConnection2,connection);
    cmdSPCGJH_D.Fill(ds,"SPCGJH_D");

在sqlConnection2中我传了一个参数给where条件,这样在ds的表SPCGJH_D中就只有特定的 项目才会显示出来!  
 
另外可以通过
ds.Tables["SPCGJH_D"].DefaultView.RowFilter="JHBM='"+WebTextEdit1.Text+"'";
来做同样的事情。
posted on 2004-11-16 14:57  mengfan  阅读(542)  评论(0编辑  收藏  举报