Query
-
I have tried something like this, but not working : conn.Open(); // i want all these values(in bold) in one variable to be displayed later(in a messagebox). Is it possible to display these 5 values in one variable? how? SqlCommand cmm = new SqlCommand("select url, sitehit, survey, tellafriend, addtooutlook from tblsummary", conn); SqlDataAdapter ad = new SqlDataAdapter(cmm); DataSet sd = new DataSet(); ad.Fill(sd, "tblsummary"); //string str = sd.Tables(0).Rows(0).Item(0); //for (i = 0 To ds.Tables(0).Rows.Count) for(int i = 0;i<=ds.Tables(0);i++) { string str = sd.Tables(0); MessageBox.Show(str); } It is giving error at ".Rows(0)" (wich is commented). Is it proper? Thanx 4 d response in adv. Regards nekshan.
-
I have tried something like this, but not working : conn.Open(); // i want all these values(in bold) in one variable to be displayed later(in a messagebox). Is it possible to display these 5 values in one variable? how? SqlCommand cmm = new SqlCommand("select url, sitehit, survey, tellafriend, addtooutlook from tblsummary", conn); SqlDataAdapter ad = new SqlDataAdapter(cmm); DataSet sd = new DataSet(); ad.Fill(sd, "tblsummary"); //string str = sd.Tables(0).Rows(0).Item(0); //for (i = 0 To ds.Tables(0).Rows.Count) for(int i = 0;i<=ds.Tables(0);i++) { string str = sd.Tables(0); MessageBox.Show(str); } It is giving error at ".Rows(0)" (wich is commented). Is it proper? Thanx 4 d response in adv. Regards nekshan.
conn.Open(); SqlCommand cmm = new SqlCommand("select url, sitehit, survey, tellafriend, addtooutlook from tblsummary", conn); SqlDataAdapter ad = new SqlDataAdapter(cmm); DataSet ds = new DataSet(); ad.Fill(ds, "tblsummary"); string str Dim ds As DataSet1 if (ds.Tables(0).Rows.Count != 0) { string str =""; Str = ds.Tables(0).Rows(0).Item(1).ToString(); ' i think item is starts from 0 if not work then write here 0 then 1 upto 4 ok. str += ds.Tables(0).Rows(0).Item(2).ToString(); str += ds.Tables(0).Rows(0).Item(3).ToString(); str += ds.Tables(0).Rows(0).Item(4).ToString(); str += ds.Tables(0).Rows(0).Item(5).ToString(); } MessageBox.Show(str); run in debug mode with putting break point over this code so u get it better. if it skip if condition then no row is coming from database ok so check query if not going in if condition. replay me feedback after testing.
-
I have tried something like this, but not working : conn.Open(); // i want all these values(in bold) in one variable to be displayed later(in a messagebox). Is it possible to display these 5 values in one variable? how? SqlCommand cmm = new SqlCommand("select url, sitehit, survey, tellafriend, addtooutlook from tblsummary", conn); SqlDataAdapter ad = new SqlDataAdapter(cmm); DataSet sd = new DataSet(); ad.Fill(sd, "tblsummary"); //string str = sd.Tables(0).Rows(0).Item(0); //for (i = 0 To ds.Tables(0).Rows.Count) for(int i = 0;i<=ds.Tables(0);i++) { string str = sd.Tables(0); MessageBox.Show(str); } It is giving error at ".Rows(0)" (wich is commented). Is it proper? Thanx 4 d response in adv. Regards nekshan.
Nekshan wrote:
//string str = sd.Tables(0).Rows(0).Item(0); //for (i = 0 To ds.Tables(0).Rows.Count) for(int i = 0;i<=ds.Tables(0);i++) { string str = sd.Tables(0); MessageBox.Show(str); }
Try changing () to [].
Nekshan wrote:
string str = sd.Tables(0);
How can u assign table object to string ?
printf("Navaneeth!!") www.w3hearts.com
-
Nekshan wrote:
//string str = sd.Tables(0).Rows(0).Item(0); //for (i = 0 To ds.Tables(0).Rows.Count) for(int i = 0;i<=ds.Tables(0);i++) { string str = sd.Tables(0); MessageBox.Show(str); }
Try changing () to [].
Nekshan wrote:
string str = sd.Tables(0);
How can u assign table object to string ?
printf("Navaneeth!!") www.w3hearts.com
You can simplay conconate the output fild in sql query like select field1+field2+....+finldn as newfieldname from tablename now you get only one value per row then as same as you have done Check it I have not try but soure about it.