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. Web Development
  3. ASP.NET
  4. Inserting data and image into SQL

Inserting data and image into SQL

Scheduled Pinned Locked Moved ASP.NET
databasehelp
3 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.
  • N Offline
    N Offline
    NnAsp net
    wrote on last edited by
    #1

    :((Please help!! I working on a simple CMS. On the admin page I have a Textarea/(WSYWIG editor(HTMLAREA)) where the user can type the content of the page. Then on the same page I have a usercontrol to upload images in the database in table image. But when I click on teh upload button the page gets posted and I am not able to get the image id field from the new record in the pageload event when the page posts(that is how I can the HTMLcode of the content from the editor) to insert in the pagecontent table. Hope this makes sense. Basially what I need help is with inserting data into different tables but i need the primary key from the image table to insert as the foreign key in the pagecontent table. Thanks in advance and I would really appreciate if someone can help ASAP!!!!

    R 1 Reply Last reply
    0
    • N NnAsp net

      :((Please help!! I working on a simple CMS. On the admin page I have a Textarea/(WSYWIG editor(HTMLAREA)) where the user can type the content of the page. Then on the same page I have a usercontrol to upload images in the database in table image. But when I click on teh upload button the page gets posted and I am not able to get the image id field from the new record in the pageload event when the page posts(that is how I can the HTMLcode of the content from the editor) to insert in the pagecontent table. Hope this makes sense. Basially what I need help is with inserting data into different tables but i need the primary key from the image table to insert as the foreign key in the pagecontent table. Thanks in advance and I would really appreciate if someone can help ASAP!!!!

      R Offline
      R Offline
      Ryan Bost
      wrote on last edited by
      #2

      You didn't provide what type of database you are using, so I can't provide you with syntax. But I will provide you with the logic you need. There is no need to perform the insert of the image record before the postback and the following record after the postback. You can perform both inserts prior to the postback. When you first submit the form, insert the image record into the database. You should return an output parameter containing the primary key of the newly added image record from the SQL code. Grab this value with your .NET code. Then perform an insert to the pagecontent table supplying the retrieved value as an input parameter. NOTE: You will probably want to (eventually) encompass both insert statements within a transaction so that they both succeed or both fail, but that is an entirely different discussion. Hope this helps. If not, supply some more information (i.e. .NET language C#/VB, database type SQL Server/Access/etc, database table structures, or post your code). Good luck. Ryan Bost http://www.sugarcoding.com

      N 1 Reply Last reply
      0
      • R Ryan Bost

        You didn't provide what type of database you are using, so I can't provide you with syntax. But I will provide you with the logic you need. There is no need to perform the insert of the image record before the postback and the following record after the postback. You can perform both inserts prior to the postback. When you first submit the form, insert the image record into the database. You should return an output parameter containing the primary key of the newly added image record from the SQL code. Grab this value with your .NET code. Then perform an insert to the pagecontent table supplying the retrieved value as an input parameter. NOTE: You will probably want to (eventually) encompass both insert statements within a transaction so that they both succeed or both fail, but that is an entirely different discussion. Hope this helps. If not, supply some more information (i.e. .NET language C#/VB, database type SQL Server/Access/etc, database table structures, or post your code). Good luck. Ryan Bost http://www.sugarcoding.com

        N Offline
        N Offline
        NnAsp net
        wrote on last edited by
        #3

        Thanks for replying Ryan, I have tried many different ways of making this work but to no avail. I will appreciate if you can take alook at my code and help me with the syntax. I am using vb.net and SQL server database. And if you know of a better wsywig editor please let me know.

        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