需要一个数据连接适配器吧!
 
查询语句:
"select * from aaa where b_column like '%str_a%' or b_column like '%str_b%'"

解决方案 »

  1.   

    DataSet DS=new DataSet();
    cn.open();
    SqlDataAdapter Da=new SqlDataAdapter(select * from aaa where charindex(str_a,b_column)>=0 or charindex(str_b,b_column)>=0,cn);
    Da.Fill(DS,"table");
    DataGrid1.DataSource=DS.Tables[0].DefaultView;
    DataGrid1.DataBind();
      

  2.   

    DataSet DS=new DataSet();
    cn.open();
    sql = "select * from aaa where b_column like '%str_a%' and b_column like '%str_b%'";
    SqlDataAdapter Da=new SqlDataAdapter(sql,cn);
    Da.Fill(DS,"table");
    DataGrid1.DataSource=DS.Tables[0].DefaultView;
    DataGrid1.DataBind();
      

  3.   

    sql = "select * from aaa where b_column like '%str_a%' and b_column like '%str_b%'";同时包含用 and 包含一个用 or
      

  4.   

    关键就是这个:
    sql = "select * from aaa where b_column like '%str_a%' and b_column like '%str_b%'";同时包含用 and 包含一个用 or这些楼上的兄弟已经说了:(
      

  5.   

    程序出错了:
    未处理的“System.Data.SqlClient.SqlException”类型的异常出现在 system.data.dll 中。
    其他信息: 系统错误。
    tableName = "T_i_00_A";
    string SQLString = "select * from " + tableName + " where aufnr like '%NA0310%' ";
    common.theAdapter = new SqlDataAdapter( SQLString , common.Cn);
    common.theDataSet = new DataSet();  
    common.theAdapter.Fill(common.theDataSet, ??? );-------停在此句了。请问:此处的表名是自己设置的吗,是否要和下面一句的???对应起来
    this.dataGrid1.DataSource = common.theDataSet.Tables[???]; 
      

  6.   

    select * from 表 where 字段 like '%关键字%'或:
    select * from 表 where charindex('关键字',字段)>0或:
    select * from 表 where patindex('%关键字%',字段)>0
      

  7.   

    表名应该为变量。
       
    @tableName  varchar(10)@tableName=txtTableName.text
      

  8.   

    你的sql语句有问题
    如果NA0310为变量
    string SQLString = "select * from T_i_00_A  like %"+NA0310+"% ";
      

  9.   

    我觉得dategrid不太好用,所以最好自己写一个grid的对象,加上一些属性和方法