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. Getting data from a grid to a dataset to save [modified]

Getting data from a grid to a dataset to save [modified]

Scheduled Pinned Locked Moved Database
helpcssdatabasebeta-testingquestion
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.
  • I Offline
    I Offline
    IMC2006
    wrote on last edited by
    #1

    I am working on getting data out of a datagrid, and save it to a SQL data base. I have the following code: // Create parameters for the QA_Setup dataset via Sqlcommand SqlCommand cmd = new SqlCommand(); // Define the params for each column in QA_SetUp // cmd.Parameters.Add("@CompanyName", SqlDbType.VarChar, 50, ds.Tables("CompanyName").column("CompanyName")); cmd.Parameters.Add("@CompanyName", SqlDbType.VarChar, 50, "CompanyName"); cmd.Parameters.Add("@CompanyCode", SqlDbType.VarChar, 50, "CompanyCode"); cmd.Parameters.Add("@InspectionPrefix", SqlDbType.VarChar, 50, "InspectionPrefix"); cmd.Parameters.Add("@TestPrefix", SqlDbType.VarChar, 50, "TestPrefix"); cmd.Parameters.Add("@DefectPrefix", SqlDbType.VarChar, 50, "DefectPrefix"); cmd.Parameters.Add("@AuditTrail", SqlDbType.Bit, 1, "AuditTrail"); //define connection and stored proc name cmd.Connection = conn; cmd.CommandText = sproc; // call insert command for the cmd dap.InsertCommand = cmd; When I run the app I and try and save I get a syntax error(System.Data.SQLClient.SQLException) as follows: Line1: Incorrect Syntax near 'prc_QA_Setup_ins'. This is the sproc name that is passed in. Not sure what my issue is, any idea? the sproc is declared as string sproc="prc_QA_Setup_ins"; which is passed over to my DAL which is where the code above resides. -- modified at 21:52 Tuesday 13th June, 2006

    C 1 Reply Last reply
    0
    • I IMC2006

      I am working on getting data out of a datagrid, and save it to a SQL data base. I have the following code: // Create parameters for the QA_Setup dataset via Sqlcommand SqlCommand cmd = new SqlCommand(); // Define the params for each column in QA_SetUp // cmd.Parameters.Add("@CompanyName", SqlDbType.VarChar, 50, ds.Tables("CompanyName").column("CompanyName")); cmd.Parameters.Add("@CompanyName", SqlDbType.VarChar, 50, "CompanyName"); cmd.Parameters.Add("@CompanyCode", SqlDbType.VarChar, 50, "CompanyCode"); cmd.Parameters.Add("@InspectionPrefix", SqlDbType.VarChar, 50, "InspectionPrefix"); cmd.Parameters.Add("@TestPrefix", SqlDbType.VarChar, 50, "TestPrefix"); cmd.Parameters.Add("@DefectPrefix", SqlDbType.VarChar, 50, "DefectPrefix"); cmd.Parameters.Add("@AuditTrail", SqlDbType.Bit, 1, "AuditTrail"); //define connection and stored proc name cmd.Connection = conn; cmd.CommandText = sproc; // call insert command for the cmd dap.InsertCommand = cmd; When I run the app I and try and save I get a syntax error(System.Data.SQLClient.SQLException) as follows: Line1: Incorrect Syntax near 'prc_QA_Setup_ins'. This is the sproc name that is passed in. Not sure what my issue is, any idea? the sproc is declared as string sproc="prc_QA_Setup_ins"; which is passed over to my DAL which is where the code above resides. -- modified at 21:52 Tuesday 13th June, 2006

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      IMC2006 wrote:

      Line1: Incorrect Syntax near 'prc_QA_Setup_ins'.

      Well, the code snippet that you provide doesn't even mention a stored procedure name - So, I'm guessing you've not provided all the necessary code to diagnose your problem. I am therefore guessing that somewhere you have a

      cmd.CommandText = "prc_QA_Setup_ins"

      And all you are missing is

      cmd.CommandType = CommandType.StoredProcedure


      Scottish Developers upcoming sessions include: .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy My: Website | Blog

      I 1 Reply Last reply
      0
      • C Colin Angus Mackay

        IMC2006 wrote:

        Line1: Incorrect Syntax near 'prc_QA_Setup_ins'.

        Well, the code snippet that you provide doesn't even mention a stored procedure name - So, I'm guessing you've not provided all the necessary code to diagnose your problem. I am therefore guessing that somewhere you have a

        cmd.CommandText = "prc_QA_Setup_ins"

        And all you are missing is

        cmd.CommandType = CommandType.StoredProcedure


        Scottish Developers upcoming sessions include: .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy My: Website | Blog

        I Offline
        I Offline
        IMC2006
        wrote on last edited by
        #3

        Perfect it was the cmd.CommandType = CommandType.StoredProcedure line that I was missing... thanks!

        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