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. Get many values in a variable from database.

Get many values in a variable from database.

Scheduled Pinned Locked Moved C#
databasecomtutorial
10 Posts 3 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 a function to display a popup in a form: taskbarNotifier1.Show("HostName: \n\n SiteHit: \n\n Survey: \n\n TAF: \n\n ATO: ", strQuery, 300, 2000, 300); Now these hostname,survey,taf,ato i have to get from database : strQuery = "select url,sitehit,survey,tellafriend,addtooutlook from tblsummary where datetime = now"; i.e. the last/current entry of database and store all these data in string 'strQuery' and call this variable 'strQuery' in above function taskbarNotifier1.Show in different lines ie one after other like this : |------------------------------------ | Hostname : nekshan@yahoo.com | | | Sitehit : 1 | | Survey : 0 | | tellafriend : 1 |_______________________________| These in bold are data to be displayed by the query. How to get all this data in one variable to put it in my function n display data in this format. Can i get many fields from a record of a table and store it in a variable or i have to use some other way. i dont know whether i can get many fields from a record of a table and store it in a variable. Hope to get some response. thank you nekshan. Hope u r getting my Point. Thanx nekshan.

    H V 2 Replies Last reply
    0
    • N Nekshan

      I have a function to display a popup in a form: taskbarNotifier1.Show("HostName: \n\n SiteHit: \n\n Survey: \n\n TAF: \n\n ATO: ", strQuery, 300, 2000, 300); Now these hostname,survey,taf,ato i have to get from database : strQuery = "select url,sitehit,survey,tellafriend,addtooutlook from tblsummary where datetime = now"; i.e. the last/current entry of database and store all these data in string 'strQuery' and call this variable 'strQuery' in above function taskbarNotifier1.Show in different lines ie one after other like this : |------------------------------------ | Hostname : nekshan@yahoo.com | | | Sitehit : 1 | | Survey : 0 | | tellafriend : 1 |_______________________________| These in bold are data to be displayed by the query. How to get all this data in one variable to put it in my function n display data in this format. Can i get many fields from a record of a table and store it in a variable or i have to use some other way. i dont know whether i can get many fields from a record of a table and store it in a variable. Hope to get some response. thank you nekshan. Hope u r getting my Point. Thanx nekshan.

      H Offline
      H Offline
      Harini N K
      wrote on last edited by
      #2

      Hi, 1. For concatenating Strings, use StringBuilder. Append data in a StringBuilder variable. 2. For retrieve data from the database. a.Connect to database b.Fill data in Dataset using SQL Adapter or ExecuteDataSet. c.Save this result in a Dataset variable. (Assume variable as 'ds') 3. To get value of each column ---> ds.Tables[0].Rows[0]["url"].ToString() and so on for other columns.. 4. Append those values in a StringBuilder variable. 5. Use that variable in this line (Note : Replace strQuery -> StringBuilder variable) taskbarNotifier1.Show("HostName: \n\n SiteHit: \n\n Survey: \n\n TAF: \n\n ATO: ", SB, 300, 2000, 300); Hope this is what you wanted. -Harini

      1 Reply Last reply
      0
      • N Nekshan

        I have a function to display a popup in a form: taskbarNotifier1.Show("HostName: \n\n SiteHit: \n\n Survey: \n\n TAF: \n\n ATO: ", strQuery, 300, 2000, 300); Now these hostname,survey,taf,ato i have to get from database : strQuery = "select url,sitehit,survey,tellafriend,addtooutlook from tblsummary where datetime = now"; i.e. the last/current entry of database and store all these data in string 'strQuery' and call this variable 'strQuery' in above function taskbarNotifier1.Show in different lines ie one after other like this : |------------------------------------ | Hostname : nekshan@yahoo.com | | | Sitehit : 1 | | Survey : 0 | | tellafriend : 1 |_______________________________| These in bold are data to be displayed by the query. How to get all this data in one variable to put it in my function n display data in this format. Can i get many fields from a record of a table and store it in a variable or i have to use some other way. i dont know whether i can get many fields from a record of a table and store it in a variable. Hope to get some response. thank you nekshan. Hope u r getting my Point. Thanx nekshan.

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

        i have soln but if u know how to create stored procedure then i send u ok. reply me u know or not.

        N 1 Reply Last reply
        0
        • V virendra patel

          i have soln but if u know how to create stored procedure then i send u ok. reply me u know or not.

          N Offline
          N Offline
          Nekshan
          wrote on last edited by
          #4

          Without stored procedure the solution won't work or what? No, I donno how to create storedprocedures. But i'll learn. Is it too complex or hard to learn? Today i m not feeling well, so i may work on it 2mrw, but u can send i'll study it, just explain in a bit detail. Thanx n Regards Nekshan.

          V 1 Reply Last reply
          0
          • N Nekshan

            Without stored procedure the solution won't work or what? No, I donno how to create storedprocedures. But i'll learn. Is it too complex or hard to learn? Today i m not feeling well, so i may work on it 2mrw, but u can send i'll study it, just explain in a bit detail. Thanx n Regards Nekshan.

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

            ' I ALLREADY SENT U THIS ANSWER WITHOUT STORED PROCEDURE IN ONE QUESTION REPLAY SO REFERE IT.OK.BYE.TC.

            N 1 Reply Last reply
            0
            • V virendra patel

              ' I ALLREADY SENT U THIS ANSWER WITHOUT STORED PROCEDURE IN ONE QUESTION REPLAY SO REFERE IT.OK.BYE.TC.

              N Offline
              N Offline
              Nekshan
              wrote on last edited by
              #6

              hi!! Function can only return one value so if u want all three then u have to concat all in one variable like str = str1 + "#" + str2 + "#" + str3 then return str from function now on form u've to seperate all 3 from str by using mid(str,"#",1) like dis not exactly dis function is. u have to seperate like this all in different variable then use it. U r talking abt this answer? Y do i separate it using 'mid(str,"#",1)' on form? -- bcoz i have to display it one by one in a line?

              V 1 Reply Last reply
              0
              • N Nekshan

                hi!! Function can only return one value so if u want all three then u have to concat all in one variable like str = str1 + "#" + str2 + "#" + str3 then return str from function now on form u've to seperate all 3 from str by using mid(str,"#",1) like dis not exactly dis function is. u have to seperate like this all in different variable then use it. U r talking abt this answer? Y do i separate it using 'mid(str,"#",1)' on form? -- bcoz i have to display it one by one in a line?

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

                ' no i sent 1 fun which return dataset so use any variable directly as u like i think in prev question of this.on saturday.

                V 1 Reply Last reply
                0
                • V virendra patel

                  ' no i sent 1 fun which return dataset so use any variable directly as u like i think in prev question of this.on saturday.

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

                  U GET IN or i will send the code to seperate value from string. replay me.

                  N 1 Reply Last reply
                  0
                  • V virendra patel

                    U GET IN or i will send the code to seperate value from string. replay me.

                    N Offline
                    N Offline
                    Nekshan
                    wrote on last edited by
                    #9

                    I m not feeling well 2day, so i m going. I'll surely test it 2mrw. Thanx yar. Sorry! tari jode bou mehnat karau chu. Aje bau weaknes lageche.so... Bye thanx cu.tc. nekshan.

                    V 1 Reply Last reply
                    0
                    • N Nekshan

                      I m not feeling well 2day, so i m going. I'll surely test it 2mrw. Thanx yar. Sorry! tari jode bou mehnat karau chu. Aje bau weaknes lageche.so... Bye thanx cu.tc. nekshan.

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

                      ok bye.tc

                      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