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. varchar(max) in database - how to put the size in ADO.NET

varchar(max) in database - how to put the size in ADO.NET

Scheduled Pinned Locked Moved C#
helpcsharpdatabasetutorial
7 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.
  • U Offline
    U Offline
    User 7763270
    wrote on last edited by
    #1

    Hi, I have field in database and it is defined as Varchar(max). And in the front in ADO.NET I am trying with the options AddParamToSQLCmd(sqlCmd, "@Comments", SqlDbType.VarChar, -1, ParameterDirection.Input, pArg.Comments); SqlDbType.NVarChar, -1 SqlDbType.VarChar, -1 SqlDbType.NText, -1 and nothing seemed working. I am trying to insert over some 48000 charecters but it is storing only 43500 some charecters. Not sure if I am missing some thing. Am I doing it right or can some one please help me how to get around this issue. Thanks in advance L

    E J 2 Replies Last reply
    0
    • U User 7763270

      Hi, I have field in database and it is defined as Varchar(max). And in the front in ADO.NET I am trying with the options AddParamToSQLCmd(sqlCmd, "@Comments", SqlDbType.VarChar, -1, ParameterDirection.Input, pArg.Comments); SqlDbType.NVarChar, -1 SqlDbType.VarChar, -1 SqlDbType.NText, -1 and nothing seemed working. I am trying to insert over some 48000 charecters but it is storing only 43500 some charecters. Not sure if I am missing some thing. Am I doing it right or can some one please help me how to get around this issue. Thanks in advance L

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #2

      Varchar max is 8000, Nvarchar is 4000. If you need more than that use text. http://msdn.microsoft.com/en-us/library/ms176089.aspx[^] http://msdn.microsoft.com/en-us/library/ms186939.aspx[^]

      Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

      U J P 3 Replies Last reply
      0
      • E Ennis Ray Lynch Jr

        Varchar max is 8000, Nvarchar is 4000. If you need more than that use text. http://msdn.microsoft.com/en-us/library/ms176089.aspx[^] http://msdn.microsoft.com/en-us/library/ms186939.aspx[^]

        Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

        U Offline
        U Offline
        User 7763270
        wrote on last edited by
        #3

        I tried with the Text but the same thing it can't store more than 43567 charecters. I also tried updating the Text database field that I just created for testing in the management studio but no luck. For some unknown reason it is storing only 43567 charecteros of text. Any inputs towards fixing this issue is greatly appreciated. Thanks, L

        1 Reply Last reply
        0
        • E Ennis Ray Lynch Jr

          Varchar max is 8000, Nvarchar is 4000. If you need more than that use text. http://msdn.microsoft.com/en-us/library/ms176089.aspx[^] http://msdn.microsoft.com/en-us/library/ms186939.aspx[^]

          Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

          J Offline
          J Offline
          jschell
          wrote on last edited by
          #4

          Ennis Ray Lynch, Jr. wrote:

          Varchar max is 8000, Nvarchar is 4000. If you need more than that use text.

          Both of those links specifically mention 'varchar(max)' which takes 2 gigs. And the OP is already successfully storing more than 8000 as well.

          E 1 Reply Last reply
          0
          • U User 7763270

            Hi, I have field in database and it is defined as Varchar(max). And in the front in ADO.NET I am trying with the options AddParamToSQLCmd(sqlCmd, "@Comments", SqlDbType.VarChar, -1, ParameterDirection.Input, pArg.Comments); SqlDbType.NVarChar, -1 SqlDbType.VarChar, -1 SqlDbType.NText, -1 and nothing seemed working. I am trying to insert over some 48000 charecters but it is storing only 43500 some charecters. Not sure if I am missing some thing. Am I doing it right or can some one please help me how to get around this issue. Thanks in advance L

            J Offline
            J Offline
            jschell
            wrote on last edited by
            #5

            Don't change the type around. Isn't there a way to set the parameter without specifying a size? (I can't find a reference to 'AddParamToSQLCmd') > but it is storing only 43500 some charecters. Specifically, and in detail, how did you determine that?

            1 Reply Last reply
            0
            • J jschell

              Ennis Ray Lynch, Jr. wrote:

              Varchar max is 8000, Nvarchar is 4000. If you need more than that use text.

              Both of those links specifically mention 'varchar(max)' which takes 2 gigs. And the OP is already successfully storing more than 8000 as well.

              E Offline
              E Offline
              Ennis Ray Lynch Jr
              wrote on last edited by
              #6

              Huh, never actually noticed. I could have sworn MAX was a synonym for 4000 and 8000 respectively. Learn something new everyday.

              Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

              1 Reply Last reply
              0
              • E Ennis Ray Lynch Jr

                Varchar max is 8000, Nvarchar is 4000. If you need more than that use text. http://msdn.microsoft.com/en-us/library/ms176089.aspx[^] http://msdn.microsoft.com/en-us/library/ms186939.aspx[^]

                Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

                P Offline
                P Offline
                Prasanta_Prince
                wrote on last edited by
                #7

                Good one.

                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