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. Sending data to database

Sending data to database

Scheduled Pinned Locked Moved Database
databasecsharpsql-serversysadminquestion
4 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.
  • P Offline
    P Offline
    Phanindra261
    wrote on last edited by
    #1

    I have a class and the data in it has to be stored in the database. I have done this by extracting every single property and sending each of them as input parameters to a stored procedure in the database. But the thing is that the class has too many properties. Is there any way to accomplish this in a single go(lesser amount of code)? OH and I am using C# and Sql Server!

    J M 2 Replies Last reply
    0
    • P Phanindra261

      I have a class and the data in it has to be stored in the database. I have done this by extracting every single property and sending each of them as input parameters to a stored procedure in the database. But the thing is that the class has too many properties. Is there any way to accomplish this in a single go(lesser amount of code)? OH and I am using C# and Sql Server!

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

      Presumably it throws an exception and posting that exception as part of your post is helpful. Presuming that the exception is telling you the statement is too big... If your SQL statement is too long then SQL/C# will have a problem with it. The solution is to reduce the size. (Might note that that could indicate a database design issue as well.) Using the database import tools (sqlldr?) might help with the problem but might not. If not or you don't want to use it then solutions. 1. Do two calls. 2. Pass in a blob and parse it to create dynamic sql. If it was me I would presume that there is a design issue.

      1 Reply Last reply
      0
      • P Phanindra261

        I have a class and the data in it has to be stored in the database. I have done this by extracting every single property and sending each of them as input parameters to a stored procedure in the database. But the thing is that the class has too many properties. Is there any way to accomplish this in a single go(lesser amount of code)? OH and I am using C# and Sql Server!

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

        As has been mentioned, if the table has too many field then there is probably a design problem. Communication with the database is donkey work, most developers use or write a code generator for this. I have not hand coded DAL for many years.

        Never underestimate the power of human stupidity RAH

        P 1 Reply Last reply
        0
        • M Mycroft Holmes

          As has been mentioned, if the table has too many field then there is probably a design problem. Communication with the database is donkey work, most developers use or write a code generator for this. I have not hand coded DAL for many years.

          Never underestimate the power of human stupidity RAH

          P Offline
          P Offline
          Phanindra261
          wrote on last edited by
          #4

          The thing is I am still new. Is it not good that we do more of the grunt work at the starting stages itself? And DAL coding is quite hectic. Sometimes I really feel why do we need it anyway. Thank you for eye opener atleast.

          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