ASP.NET-asp.net 不存在此行/列的数据
OleDbConnection myConn = DB.createDB();
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["id"].ToString() != "add")
{
myConn.Open();
OleDbCommand RsCommand_GetData = new OleDbCommand("select * from [bin_notes] where [id] =" + Request.QueryString["id"].ToString(), myConn);
OleDbDataReader DataReader_GetData = RsCommand_GetData.ExecuteReader();
this.title.Text = DataReader_GetData["title"].ToString();
this.myEditor.InnerText = DataReader_GetData["content"].ToString();
DataReader_GetData.Close();
RsCommand_GetData.Dispose();
myConn.Close();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
if (Request.QueryString["id"].ToString() != "add")
{
myConn.Open();
OleDbCommand RsCommand_GetData = new OleDbCommand("select top 1 id,title,content from [bin_notes] where [id] =" + Request.QueryString["id"].ToString(), myConn);
using (OleDbDataReader DataReader_GetData = RsCommand_GetData.ExecuteReader(CommandBehavior.CloseConnection))
{
if (DataReader_GetData.Read())
{
this.title.Text = DataReader_GetData.GetString(1);//字段顺序一定要写对,0开始
this.myEditor.InnerText = DataReader_GetData.GetString(2);
}
}
RsCommand_GetData.Dispose();
myConn.Close();
}
自己解决了,最后改成了这样!