SQL语句如下:
select ProductId,ProductName,ProductImage,ProductNo,ProductMade,ProductIntor,ProductTypeId,addTime FROM ProductInfo where ProductName like '*电器*' or ProductIntor like '*电器*'
然后这条SQL语句放到access中运行,是有返回数据的。
但是当我用asp.net运行的时候 却死活得不到数据。
代码如下:
public static DataSet Query(string SQLString)
{
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
DataSet ds = new DataSet();
try
{
connection.Open();
OleDbDataAdapter command = new OleDbDataAdapter(SQLString, connection);
command.Fill(ds, "ds");
}
catch (System.Data.OleDb.OleDbException ex)
{
throw new Exception(ex.Message);
}
return ds;
}
}
SQLString = select ProductId,ProductName,ProductImage,ProductNo,ProductMade,ProductIntor,ProductTypeId,addTime FROM ProductInfo where ProductName like '*电器*' or ProductIntor like '*电器*'connectionString = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\工作\上海斯加\SJa\SJaWeb\App_Data\SJaDB.mdb;Persist Security Info=Falseaccess是2003的版本 VS是2008
会不会是因为ado.net版本不正确所导致的得不到查询结果呢
select ProductId,ProductName,ProductImage,ProductNo,ProductMade,ProductIntor,ProductTypeId,addTime FROM ProductInfo where ProductName like '*电器*' or ProductIntor like '*电器*'
然后这条SQL语句放到access中运行,是有返回数据的。
但是当我用asp.net运行的时候 却死活得不到数据。
代码如下:
public static DataSet Query(string SQLString)
{
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
DataSet ds = new DataSet();
try
{
connection.Open();
OleDbDataAdapter command = new OleDbDataAdapter(SQLString, connection);
command.Fill(ds, "ds");
}
catch (System.Data.OleDb.OleDbException ex)
{
throw new Exception(ex.Message);
}
return ds;
}
}
SQLString = select ProductId,ProductName,ProductImage,ProductNo,ProductMade,ProductIntor,ProductTypeId,addTime FROM ProductInfo where ProductName like '*电器*' or ProductIntor like '*电器*'connectionString = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\工作\上海斯加\SJa\SJaWeb\App_Data\SJaDB.mdb;Persist Security Info=Falseaccess是2003的版本 VS是2008
会不会是因为ado.net版本不正确所导致的得不到查询结果呢
我就是用% 换成了 *的因为access和sql的通配符不一样,access不认识% 只认识 *
我觉得我好悲剧啊