我有一个两页的网站-一个页面显示文档列表,另一个编辑该文档的属性。
现在,如果我编辑文档的属性,保存所做的更改,我可以看到数据库中的数据已更改。但是当我重新加载文档列表时,该列表包含了旧数据。点击刷新,将显示修改后的数据。
如果我跟踪这些更改,它看起来确实像是返回了旧数据。
我尝试过在URL中传递刻度数,让IE加载一个新版本--但它仍然显示旧版本的数据。即使我刷新了页面,它也发生了变化--显示相同的文档详细信息,并显示旧版本的数据,再次刷新,它就会更新。
我已经检查了底层数据库中的数据是否正在更改。
所以接下下面的电话
using (nhs_patient_document_s documents = new nhs_patient_document_s(Properties.Settings.Default.DataConnectionEDM))
{
List<nhs_patient_document> found = documents.Select<nhs_patient_document>("nhs_patdoc_patientid", String.IsNullOrEmpty(criteria) ? String.Empty : criteria);
output = JsonConvert.SerializeObject(found);
}
最终,这是执行查询的代码
public List<T> Select<T>(String Field, String Value)
{
List<T> results = null;
String sql = String.Empty;
try
{
sql = (String.Format("select * From {0} Where {1} = '{2}'", TableName, Field, Value.Replace("'", "''")));
results = Execute<T>(sql, CommandType.Text);
}
catch (System.Exception e)
{
throw e;
}
finally
{
sql = String.Empty;
}
return results;
}
上面调用的execute函数如下;
protected List<T> Execute<T>(String CommandString, CommandType CommandType)
{
DataSet dataSet = null;
SqlConnection connection = null;
SqlCommand command = null;
SqlDataAdapter dataAdapter = null;
List<T> results = null;
try
{
connection = new SqlConnection(connectionString);
command = new SqlCommand(CommandString, connection);
command.CommandType = CommandType;
command.CommandTimeout = 0;
if (connection.State != ConnectionState.Open) connection.Open();
dataSet = new DataSet();
dataAdapter = new SqlDataAdapter(command);
dataAdapter.Fill(dataSet);
results = ExtractData<T>(dataSet);
}
catch ( System.Exception e)
{
throw e;
}
return results;
}
任何想法,我可以强制它从服务器获取新数据。
PS感谢其他框架的建议,但我只有很短的时间来写这篇文章,没有时间去学习它们。
https://stackoverflow.com/questions/41509626
复制相似问题