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. Database & SysAdmin
  3. Database
  4. Advantages of SQL data types like SqlString vs String

Advantages of SQL data types like SqlString vs String

Scheduled Pinned Locked Moved Database
databasequestioncsharpvisual-studioperformance
5 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.
  • T Offline
    T Offline
    Talal Sultan
    wrote on last edited by
    #1

    Hi, I would like to know what is the advantage of using Sql types in C# like SqlString, SqlInt32,etc... versus the normal type string, int etc... The scenario: Having a class representing each table of the database. Each class has Insert, Update, Select, Delete methods (plus possible others) to perform those operations on the specific table represented by the class. Will there be a significant improvement of performance if my class variables are SQL types or not really? Thanks for the insight. Talal "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook

    R R 2 Replies Last reply
    0
    • T Talal Sultan

      Hi, I would like to know what is the advantage of using Sql types in C# like SqlString, SqlInt32,etc... versus the normal type string, int etc... The scenario: Having a class representing each table of the database. Each class has Insert, Update, Select, Delete methods (plus possible others) to perform those operations on the specific table represented by the class. Will there be a significant improvement of performance if my class variables are SQL types or not really? Thanks for the insight. Talal "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook

      R Offline
      R Offline
      Rob Graham
      wrote on last edited by
      #2

      Depending on how you use those classes, it could even hurt performance. Type conversion is going to occur every time you need to display or update a class instance variable that is SqlString, for example. On the other hand the conversion would normally only happen once per database read or write if the variables were normal String types. Also, it's normally better to model your classes after business objects, rather than the database structures, that makes it easier to co-ordinate multi-table updates.

      T 1 Reply Last reply
      0
      • R Rob Graham

        Depending on how you use those classes, it could even hurt performance. Type conversion is going to occur every time you need to display or update a class instance variable that is SqlString, for example. On the other hand the conversion would normally only happen once per database read or write if the variables were normal String types. Also, it's normally better to model your classes after business objects, rather than the database structures, that makes it easier to co-ordinate multi-table updates.

        T Offline
        T Offline
        Talal Sultan
        wrote on last edited by
        #3

        Thank you for the advice. You're right, I do perform a lot of type conversion everytime I want to display or update data from the database. I guess I will revert back to normal types :) Talal "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook

        1 Reply Last reply
        0
        • T Talal Sultan

          Hi, I would like to know what is the advantage of using Sql types in C# like SqlString, SqlInt32,etc... versus the normal type string, int etc... The scenario: Having a class representing each table of the database. Each class has Insert, Update, Select, Delete methods (plus possible others) to perform those operations on the specific table represented by the class. Will there be a significant improvement of performance if my class variables are SQL types or not really? Thanks for the insight. Talal "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook

          R Offline
          R Offline
          r stropek
          wrote on last edited by
          #4

          Hi! Don't forget that there is another big difference between Sqlxxx types and the normal types: Sqlxxx types can be null (Property Null). If your fields support null-values you should use Sqlxxx types. Regards, Rainer. Rainer Stropek Visit my blog at http://www.cubido.at/rainers

          T 1 Reply Last reply
          0
          • R r stropek

            Hi! Don't forget that there is another big difference between Sqlxxx types and the normal types: Sqlxxx types can be null (Property Null). If your fields support null-values you should use Sqlxxx types. Regards, Rainer. Rainer Stropek Visit my blog at http://www.cubido.at/rainers

            T Offline
            T Offline
            Talal Sultan
            wrote on last edited by
            #5

            Hi, Yes exactly, I do have some fields that are allowed to be null, in fact I decided to use Sqlxxx types because of that null thing, but I guess I can get around this by putting empty strings for string values and some special integer value (like -1) for int values. Thanks for pointing this out. Talal "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook

            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