比如。标题,内容,日期。。我用select id,标题,内容,日期 from notepaper Order by id desc;显示,那个内容里太多了。占资源。。而我用不着。所以只想显示内容的前面20个字符串出来。
我想绑定在DATAGird里...

解决方案 »

  1.   

    select id,标题,left(内容,20),日期 from notepaper Order by id desc
      

  2.   

    另外一种:
    select id,标题,substring(内容,1,20),日期 from notepaper Order by id desc
      

  3.   

    string m_strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Application.StartupPath+""+"\\"+"notepaper.mdb";
    OleDbConnection con = new OleDbConnection( m_strConnection );
    con.Open();
    ds=new DataSet();
    //string strcmd="select id,标题,内容,日期 from notepaper Order by id desc";
    string strcmd="select id,标题,substring(内容,1,20),日期 from notepaper Order by id desc";
    adapter = new OleDbDataAdapter(strcmd,con);

    adapter.Fill(ds,"note");


    dataGrid1.DataSource =ds.Tables["note"].DefaultView;

    dataGrid1.SetDataBinding(ds,"note"); 
    这样是查询语句是出错的啊..
      

  4.   

    select  id, substring(内容,1,1) from  notepaper order by id desc
    查询语句不能错.是不是你对ds  的填充有误呀 adapter=new OleDbDataAdapter(strcmd,con);
    adapter.Fill(ds,"notepaper");
    dataGrid1.SetDataBinding(ds,"note");