SQL语句如下:
select a.*,b.AName from MWell_TBS_Product a,MWell_TBS_Area b where a.AID = b.AID and ( a.PName like '*" + strSch + "*' or a.PMemo like '*" + strSch + "*')and a.CID in ( select CID from MWell_TBS_Catalog where CPID="+iCID +" )"
在Access的查询分析器中可以查询出结果,可是在
 public  DataTable GetDataTable(string strSQL)
        {   
            string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0; " + 
                "Data Source=" + HttpContext.Current.Server.MapPath(strDataPath);
            string strCommandText =strSQL;            OleDbConnection myConnection = new OleDbConnection(strConnection);
            myConnection.Open();
            OleDbDataAdapter myAdpater = new OleDbDataAdapter(strSQL,myConnection);
            OleDbCommandBuilder myBuilder = new OleDbCommandBuilder(myAdpater);
            DataSet myDataset = new DataSet();
            myAdpater.Fill(myDataset);
            DataTable mytable = myDataset.Tables[0];
            myConnection.Close();
            return mytable;
        }
这种方式下传入SQL,查询得到的结果却是空的,为什么???希望大家指点指点?

解决方案 »

  1.   

    估计是SQL语句的问题ACCESS的写法和SQL有些小的地方是不一样的
      

  2.   

    try this
    select a.*,b.AName from MWell_TBS_Product a,MWell_TBS_Area b where a.AID = b.AID and ( a.PName like '%" + strSch + "%' or a.PMemo like '%" + strSch + "%')and a.CID in ( select CID from MWell_TBS_Catalog where CPID="+iCID +" )"
      

  3.   

    是这里的结果为空,还是显示时为空,如果是用DataGrid显示,不要忘了yourGrid.DataBind()
      

  4.   

    你直接测试一下myDataset 中有没有数据
      

  5.   

    swife(): 你的写法是错误的,在SQL中是写%,在access中是*hedongfu(何东付) : sql语句在access中的查询中可以显示出结果,而在返回的ds中是没有结果的.
    oldmoon(浪者) : ds结果中没有数据测试过了,但是在查询中可以查到数据