A
Andy Sutorius
Hi,
I am getting the error "Invalid attempt to read when no data is present"
when I run the following code. I have checked the sql and it is returning
data. What am I missing?
string sqlGetEmail = "SELECT content, subject FROM tblContent WHERE id =
" + Convert.ToInt16(ddlChooseEmail.SelectedValue.ToString());
SqlCommand cmdGetEmail = new SqlCommand(sqlGetEmail, strConnString);
SqlDataReader dtrEmail = cmdGetEmail.ExecuteReader();
string strSubject = Convert.ToString(dtrEmail["subject"]);
string strContent = Convert.ToString(dtrEmail["content"]);
dtrEmail.Close();
Thanks,
Andy
I am getting the error "Invalid attempt to read when no data is present"
when I run the following code. I have checked the sql and it is returning
data. What am I missing?
string sqlGetEmail = "SELECT content, subject FROM tblContent WHERE id =
" + Convert.ToInt16(ddlChooseEmail.SelectedValue.ToString());
SqlCommand cmdGetEmail = new SqlCommand(sqlGetEmail, strConnString);
SqlDataReader dtrEmail = cmdGetEmail.ExecuteReader();
string strSubject = Convert.ToString(dtrEmail["subject"]);
string strContent = Convert.ToString(dtrEmail["content"]);
dtrEmail.Close();
Thanks,
Andy