Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Query

Query

Scheduled Pinned Locked Moved C#
databasehelpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nekshan
    wrote on last edited by
    #1

    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.

    V N 2 Replies Last reply
    0
    • N 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.

      V Offline
      V Offline
      virendra patel
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • N 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.

        N Offline
        N Offline
        N a v a n e e t h
        wrote on last edited by
        #3

        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

        C 1 Reply Last reply
        0
        • N N a v a n e e t h

          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

          C Offline
          C Offline
          com neeraj
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups