我有以下方法用于搜索数据库中的字段
此方法返回数据并在我的笔记本电脑本地计算机上正常工作,但当我将项目上传到服务器时,该方法不起作用并返回空数据。
注意:我的本地笔记本电脑 2008 上的 sqlserver 但在服务器 2012 上
这是方法
//this method for search
protected void fillGridView(int followingID, string text)
{
SqlCommand myCommand = new SqlCommand("select t.*,u.firstName,u.lastName,u2.firstName as afirstName,u2.lastName as alastName ,i.icon,ii.iconPath as taskIcon, iii.iconPath as seenIcon,f.fileName,f.fileID from tasks as t inner join users as u on u.userID=t.addedBy inner join users as u2 on u2.userID=t.attachTo inner join priorityIcons as i on t.priority=i.priorityID inner join icons as ii on t.status=ii.iconName inner join icons as iii on t.isNew=iii.iconName left join files as f on t.fileID=f.fileID where t.followingID=@followingID and t.description LIKE '%" + text + "%' or t.followingID=@followingID and t.title LIKE '%" + text + "%'");
myCommand.Parameters.AddWithValue("@followingID", followingID);
myCommand.Parameters.AddWithValue("@text", text);
SqlConnection con = new SqlConnection();
con.ConnectionString = connection;
myCommand.Connection = con;
con.Open();
DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter(myCommand);
try
{
adapter.Fill(ds);
tasksRepeater.DataSourceID = null;
tasksRepeater.DataSource = ds.Tables[0];
tasksRepeater.DataBind();
tasksCounter();
}
catch (Exception ex)
{
DAO.exDao myEx = new DAO.exDao();
myEx.insert(ex);
Response.Redirect("./error.aspx");
//success = false;
//throw ex;
}
}