Get data from database to dataset and again dataset to Variables?

Posted by Mandlaa under ASP.NET on 5/17/2013 | Points: 10 | Views : 1550 | Status : [Member] | Replies : 3
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"");
SqlCommand cmd;
SqlDataAdapter da;
DataSet ds;
int rno = 0;
string result;
string phone;
try
{
da = new SqlDataAdapter("select ParentFname,ParentLname,Phone,AmountDue,AmountPaid,DueDate FROM Childcare where SecurityCode='1243'", con);
ds = new DataSet();
da.Fill(ds, "Childcare");
DataTable dt = ds.Tables["Childcare"];

foreach (DataRow row in dt.Rows)
{
foreach (DataColumn col in dt.Columns)
{
string pname = row["ParentFname"].ToString();
phone = row["Phone"].ToString();
}
}
//string pname = ds.Tables["Childcare"].Rows[rno]["ParentFname"].ToString();
//string plname = ds.Tables["Childcare"].Rows[rno]["ParentLname"].ToString();
//string phone = ds.Tables["Childcare"].Rows[rno]["Phone"].ToString();
//string amodue = ds.Tables["Childcare"].Rows[rno]["AmountDue"].ToString();
//string apaid = ds.Tables["Childcare"].Rows[rno]["AmountPaid"].ToString();
//string ddate = ds.Tables["Childcare"].Rows[rno]["DueDate"].ToString();
//result = pname + plname + phone + amodue + apaid + ddate;

string ACCOUNT_SID = "c29d6563c43b3d24e";
string AUTH_TOKEN = "d5a";
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
client.SendSmsMessage("FromNumber", phone, result);

}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
}

Get values from database to dataset and again dataset to variables using data adapter,
Using datareader it working fine At the time of using dataadapter not getting
Once see my above code




Responses

Posted by: Raj.Trivedi on: 5/17/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hello Mandlaa

Try these

DataTable dt = ds.Tables.defaultView;

Regard's
Raj.Trivedi
"Sharing is Caring"
Please mark as answer if your Query is resolved

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

Posted by: Mandlaa on: 5/20/2013 [Member] Starter | Points: 25

Up
0
Down
I am using this one not solve my problem,

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

Posted by: Mandlaa on: 5/20/2013 [Member] Starter | Points: 25

Up
0
Down
any one please help me,

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

Login to post response