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. how to retrieve a single value from datatable

how to retrieve a single value from datatable

Scheduled Pinned Locked Moved C#
csharpwinformstutorialquestion
13 Posts 4 Posters 1 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.
  • L Lost User

    //code for imap connection

    What exactly are you trying to do in here?

    Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

    M Offline
    M Offline
    mschotamaster
    wrote on last edited by
    #3

    that code has been done. just i want to retrieve the single value from the table

    L 1 Reply Last reply
    0
    • M mschotamaster

      that code has been done. just i want to retrieve the single value from the table

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #4

      What value? What table? You need to provide some more details about your problem.

      Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

      M 1 Reply Last reply
      0
      • L Lost User

        What value? What table? You need to provide some more details about your problem.

        Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

        M Offline
        M Offline
        mschotamaster
        wrote on last edited by
        #5

        winforms sql2008 I have a table Login(id(int),EmailId(varchar(35),connType(varchar)) where conntype has values like pop3 or imap. consider an user is loggedin. i want to fetch connType value of the logged user to do like this if(conntypeValue == imap) { //code for imap connection }else { //code for pop3 connection } how can i do it i want to fetch connType column value from the table login where id = userid

        L 1 Reply Last reply
        0
        • M mschotamaster

          winforms sql2008 I have a table Login(id(int),EmailId(varchar(35),connType(varchar)) where conntype has values like pop3 or imap. consider an user is loggedin. i want to fetch connType value of the logged user to do like this if(conntypeValue == imap) { //code for imap connection }else { //code for pop3 connection } how can i do it i want to fetch connType column value from the table login where id = userid

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #6

          Brilliant! I asked you to explain your problem in more detail and you have just repeated your original question.

          Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

          M 1 Reply Last reply
          0
          • L Lost User

            Brilliant! I asked you to explain your problem in more detail and you have just repeated your original question.

            Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

            M Offline
            M Offline
            mschotamaster
            wrote on last edited by
            #7

            I want to connect with pop3 server or imap server on the basis of the account configured by the user. that account values are in the login table. when the user logged in. i want to fetch the value from the login table column servertype. if that value is pop3 the code of pop3 server connectivity will run.

            N 1 Reply Last reply
            0
            • M mschotamaster

              winforms sql2008 I have a table

              Login(id(int),EmailId(varchar(35),connType(varchar))

              where conntype has values like pop3 or imap. consider an user is loggedin. i want to fetch connType value of the logged user to do like this

              if(conntypeValue == imap)
              {
              //code for imap connection
              }else
              {
              //code for pop3 connection
              }

              how can i do it

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #8

              mschotamaster wrote:

              sql2008
              I have a table

              Aight, first you'd need a Sql-statement to select the value you're interested in. Something like this

              SELECT [connType]
              FROM [Login]
              WHERE [Id] = @Id

              mschotamaster wrote:

              i want to fetch connType value of the logged user to do like this

              Open a [SqlConnection](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx)[[^](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx "New Window")] (using a correct connectionstring[^]), create a [SqlCommand](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.aspx)[[^](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.aspx "New Window")], put the Sql-statement in the CommandText property, add the parameter, open the connection, and catch the result from the ExecuteScalar[^]-method.

              Bastard Programmer from Hell :suss:

              M 1 Reply Last reply
              0
              • L Lost User

                mschotamaster wrote:

                sql2008
                I have a table

                Aight, first you'd need a Sql-statement to select the value you're interested in. Something like this

                SELECT [connType]
                FROM [Login]
                WHERE [Id] = @Id

                mschotamaster wrote:

                i want to fetch connType value of the logged user to do like this

                Open a [SqlConnection](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx)[[^](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx "New Window")] (using a correct connectionstring[^]), create a [SqlCommand](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.aspx)[[^](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.aspx "New Window")], put the Sql-statement in the CommandText property, add the parameter, open the connection, and catch the result from the ExecuteScalar[^]-method.

                Bastard Programmer from Hell :suss:

                M Offline
                M Offline
                mschotamaster
                wrote on last edited by
                #9

                Yes that i want. thanks

                L L 2 Replies Last reply
                0
                • M mschotamaster

                  Yes that i want. thanks

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #10

                  My pleasure :)

                  1 Reply Last reply
                  0
                  • M mschotamaster

                    Yes that i want. thanks

                    L Offline
                    L Offline
                    Luc Pattyn
                    wrote on last edited by
                    #11

                    :confused::confused::confused::confused: if the user is logged in as you say, you must already have read the table to identify him, so you already know how to obtain data from a table.

                    Luc Pattyn [My Articles] Nil Volentibus Arduum

                    L 1 Reply Last reply
                    0
                    • L Luc Pattyn

                      :confused::confused::confused::confused: if the user is logged in as you say, you must already have read the table to identify him, so you already know how to obtain data from a table.

                      Luc Pattyn [My Articles] Nil Volentibus Arduum

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #12

                      That's what I thought also.

                      Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

                      1 Reply Last reply
                      0
                      • M mschotamaster

                        I want to connect with pop3 server or imap server on the basis of the account configured by the user. that account values are in the login table. when the user logged in. i want to fetch the value from the login table column servertype. if that value is pop3 the code of pop3 server connectivity will run.

                        N Offline
                        N Offline
                        Nathan Stiles
                        wrote on last edited by
                        #13

                        Login(id(int),EmailId(varchar(35),connType(varchar)) execute a scalar select connType from Login where id = 5 or select connType from EmailId where id = 'noone@example.com'

                        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