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. MySqlDBType equivalent of SqlDBType.Char in routines (stored procedures)

MySqlDBType equivalent of SqlDBType.Char in routines (stored procedures)

Scheduled Pinned Locked Moved Database
databasemysqlsql-serversysadminquestion
5 Posts 2 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
    TheComputerMan
    wrote on last edited by
    #1

    I have searched on the net for an answer to this, and in Code Project and I can't seem to find a definite answer. Plenty about data types in tables but little or nothing about stored procedure parameters. I am converting an SQL Server based program to run with MySql and one of the tables accessed by a procedure (routine) has a field that is the char type that is used as one the parameter fields. In procedures in SQL Server there is the SqlDBType.Char but there does not appear to be any equivalent of that in MySql (5.5) Should I just use VarChar?

    M 1 Reply Last reply
    0
    • T TheComputerMan

      I have searched on the net for an answer to this, and in Code Project and I can't seem to find a definite answer. Plenty about data types in tables but little or nothing about stored procedure parameters. I am converting an SQL Server based program to run with MySql and one of the tables accessed by a procedure (routine) has a field that is the char type that is used as one the parameter fields. In procedures in SQL Server there is the SqlDBType.Char but there does not appear to be any equivalent of that in MySql (5.5) Should I just use VarChar?

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      char(10) will deliver a string 10 characters long, padded with spaces if there is no data, varchar will deliver just the data. You need to asses whether this change will affect your output. I only use char for single character fields.

      Never underestimate the power of human stupidity RAH

      T 1 Reply Last reply
      0
      • M Mycroft Holmes

        char(10) will deliver a string 10 characters long, padded with spaces if there is no data, varchar will deliver just the data. You need to asses whether this change will affect your output. I only use char for single character fields.

        Never underestimate the power of human stupidity RAH

        T Offline
        T Offline
        TheComputerMan
        wrote on last edited by
        #3

        Thanks for responding. I understand the differences between char and varchar but what I am trying to find out is what type I should give a parameter. I have a char(1) field that accepts data in a routine. In an SQL Server stored procedure I would give this the SqlDBType.Char type. There seems to be no equivalent in MySQL so my question was do I just use MySqlDBType.VarChar?

        M 1 Reply Last reply
        0
        • T TheComputerMan

          Thanks for responding. I understand the differences between char and varchar but what I am trying to find out is what type I should give a parameter. I have a char(1) field that accepts data in a routine. In an SQL Server stored procedure I would give this the SqlDBType.Char type. There seems to be no equivalent in MySQL so my question was do I just use MySqlDBType.VarChar?

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          I think you have to use a varchar, I have no experience with MySQL, but you need to be aware that the field could end up as a null or an empty string which it cannot do if it were a char. So your client needs to be aware of this and deal with it. Reality is that you are probably using the field as a flag and it wall ALWAYS have a value.

          Never underestimate the power of human stupidity RAH

          T 1 Reply Last reply
          0
          • M Mycroft Holmes

            I think you have to use a varchar, I have no experience with MySQL, but you need to be aware that the field could end up as a null or an empty string which it cannot do if it were a char. So your client needs to be aware of this and deal with it. Reality is that you are probably using the field as a flag and it wall ALWAYS have a value.

            Never underestimate the power of human stupidity RAH

            T Offline
            T Offline
            TheComputerMan
            wrote on last edited by
            #5

            Pretty much what I was thinking. Thanks for you help.

            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