how to use datatable to retrieve data

Posted by Ankitsrist under ASP.NET on 2/26/2013 | Points: 10 | Views : 962 | Status : [Member] | Replies : 4
hello,
i have a table in database which have columns like below
id name status email
1 ankit pending an@rediffmail.com

here i want to use datatable to take data in that, to send mail to only that person whose status is pending so m confused how to use datatable to search for the values of the column status
plz help




Responses

Posted by: Santhi on: 2/26/2013 [Member] Starter | Points: 25

Up
0
Down
Hi

Get the data in the datatable by selecting the records
where the status is equal to pending from the database.
Select * from tablename where status = 'pending'


Thanks & Regards,
Santhi .V

Ankitsrist, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 2/26/2013 [Member] Starter | Points: 25

Up
0
Down
i have done this like below
public void remindermail()

{
db.myconnection();
SqlCommand cmd = new SqlCommand("select * from leavereminder", db.sqlcon);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
adp.Fill(dt);
if (dt.Rows.Count > 0)
{
if (dt.Rows[0]["status"].ToString() == "pending")
{
sendmail(dt.Rows[0]["email"].ToString(), dt.Rows[0]["name"].ToString());
}

}
}
public void sendmail(string email, string name)
{
db.myconnection();
StreamReader reader = new StreamReader(Server.MapPath("~/HTMLPage.htm"));
string readFile = reader.ReadToEnd();
string myString = "";
myString = readFile;
myString = myString.Replace("$$Admin$$", name);
myString = myString.Replace("$$CompanyName$$", "cnet infotech");


Ankitsrist, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santhi on: 2/27/2013 [Member] Starter | Points: 25

Up
0
Down
Hi

You have done in C#..
I told how to do in SQL.

Thanks & Regards,
Santhi .V

Ankitsrist, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 2/27/2013 [Member] Starter | Points: 25

Up
0
Down
thanks
yeah santhi both the ways are correct...

Ankitsrist, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response