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. Use of unassigned local variable trying to pass a sql statment through a var.

Use of unassigned local variable trying to pass a sql statment through a var.

Scheduled Pinned Locked Moved ASP.NET
databaseannouncement
11 Posts 5 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 Ibuprofen

    On Button Press, I am updating my userfeedback table certain columns, depending on who they are. private void Button1_Click(object sender, System.EventArgs e) { bool bNoError =true; OleDbConnection con = new OleDbConnection(strConnection2); string strSQL; DataSet ds = new DataSet(); CUsers user =new CUsers(); user=(CUsers)Session["SessionUser"]; switch(user.Role) { case "TL": //string strStatus=""; if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [TLComment]='"+TLComment.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"', [NeedAction]='"+NeedAction.Checked+"' WHERE autoNum="+autoNum.Text; break; case "CP": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [CPComment]='"+CPComment.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+autoNum.Text; break; case "ORA": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [ORAComments]='"+ORAComments.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+autoNum.Text; break; case "DMO": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [DMComments]='"+DMComments.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+autoNum.Text; break; case "User": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [Comments]='"+Comments.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+autoNum.Text; break; } try { OleDbDataAdapter da = new OleDbDataAdapter(strSQL,strConnection2); da.Fill(ds); DataTable mytable =ds.Tables[0]; DataRow myRow ; myRow = mytable.Rows[0];

    T Offline
    T Offline
    trooper0814
    wrote on last edited by
    #2

    string strSQL; maybe make it string strSQL = string.Empty; :confused:

    I 1 Reply Last reply
    0
    • T trooper0814

      string strSQL; maybe make it string strSQL = string.Empty; :confused:

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

      Bloops, forgot to post, I got it right after I posted here... Yes the answer was needing to make the string empty, I did so by string strSQL=""; Actualy, onto the next step of debugging, and almost certain this is my last debug error Update of the code: private void Button1_Click(object sender, System.EventArgs e) { bool bNoError =true; OleDbConnection con = new OleDbConnection(strConnection2); string strSQL=""; DataSet ds = new DataSet(); CUsers user =new CUsers(); user=(CUsers)Session["SessionUser"]; switch(user.Role) { case "TL": //string strStatus=""; if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [TLComment]='"+TLComment.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"', [NeedAction]='"+NeedAction.Checked+"' WHERE autoNum="+TicketNum.Text; break; case "CP": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [CPComment]='"+CPComment.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+TicketNum.Text; break; case "ORA": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [ORAComments]='"+ORAComments.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+TicketNum.Text; break; case "DMO": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [DMComments]='"+DMComments.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+TicketNum.Text; break; case "User": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [Comments]='"+Comments.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+TicketNum.Text; break; } try { O

      C 1 Reply Last reply
      0
      • I Ibuprofen

        Bloops, forgot to post, I got it right after I posted here... Yes the answer was needing to make the string empty, I did so by string strSQL=""; Actualy, onto the next step of debugging, and almost certain this is my last debug error Update of the code: private void Button1_Click(object sender, System.EventArgs e) { bool bNoError =true; OleDbConnection con = new OleDbConnection(strConnection2); string strSQL=""; DataSet ds = new DataSet(); CUsers user =new CUsers(); user=(CUsers)Session["SessionUser"]; switch(user.Role) { case "TL": //string strStatus=""; if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [TLComment]='"+TLComment.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"', [NeedAction]='"+NeedAction.Checked+"' WHERE autoNum="+TicketNum.Text; break; case "CP": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [CPComment]='"+CPComment.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+TicketNum.Text; break; case "ORA": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [ORAComments]='"+ORAComments.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+TicketNum.Text; break; case "DMO": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [DMComments]='"+DMComments.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+TicketNum.Text; break; case "User": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [Comments]='"+Comments.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+TicketNum.Text; break; } try { O

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

        Why do people insist on catching errors they don't know how to handle then throw away useful information! I would suspect that you shouldn't be getting a data type mismatch error at all, so why are you catching it here... Oh... I see because it it the button click event handler... Why do you have database code in the presentation layer?! You'll be glad you don't work for the company I work for. It is written into out coding standards documentation that the use of data access code in a windows or web form is a sackable offence. First, comment out the catch block. Find out exacly what is causing the exception and fix it.


        Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website

        C 1 Reply Last reply
        0
        • C Colin Angus Mackay

          Why do people insist on catching errors they don't know how to handle then throw away useful information! I would suspect that you shouldn't be getting a data type mismatch error at all, so why are you catching it here... Oh... I see because it it the button click event handler... Why do you have database code in the presentation layer?! You'll be glad you don't work for the company I work for. It is written into out coding standards documentation that the use of data access code in a windows or web form is a sackable offence. First, comment out the catch block. Find out exacly what is causing the exception and fix it.


          Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #5

          This was surely not production code ? The giveaway is that the button is called Button1....

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          I 1 Reply Last reply
          0
          • I Ibuprofen

            On Button Press, I am updating my userfeedback table certain columns, depending on who they are. private void Button1_Click(object sender, System.EventArgs e) { bool bNoError =true; OleDbConnection con = new OleDbConnection(strConnection2); string strSQL; DataSet ds = new DataSet(); CUsers user =new CUsers(); user=(CUsers)Session["SessionUser"]; switch(user.Role) { case "TL": //string strStatus=""; if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [TLComment]='"+TLComment.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"', [NeedAction]='"+NeedAction.Checked+"' WHERE autoNum="+autoNum.Text; break; case "CP": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [CPComment]='"+CPComment.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+autoNum.Text; break; case "ORA": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [ORAComments]='"+ORAComments.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+autoNum.Text; break; case "DMO": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [DMComments]='"+DMComments.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+autoNum.Text; break; case "User": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [Comments]='"+Comments.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+autoNum.Text; break; } try { OleDbDataAdapter da = new OleDbDataAdapter(strSQL,strConnection2); da.Fill(ds); DataTable mytable =ds.Tables[0]; DataRow myRow ; myRow = mytable.Rows[0];

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #6

            1 - all your code is ripe for SQL injection attacks 2 - As has been said, you should never have DB code in your presentation layer 3 - As has been said, why catch exceptions and do nothing ? 4 - use string.Empty over "", as it's more efficient 5 - Give your controls meaningful names. When someone else looks at the code, how do they know which button was button1 ?

            Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

            G I 2 Replies Last reply
            0
            • C Christian Graus

              1 - all your code is ripe for SQL injection attacks 2 - As has been said, you should never have DB code in your presentation layer 3 - As has been said, why catch exceptions and do nothing ? 4 - use string.Empty over "", as it's more efficient 5 - Give your controls meaningful names. When someone else looks at the code, how do they know which button was button1 ?

              Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

              G Offline
              G Offline
              Guffa
              wrote on last edited by
              #7

              Christian Graus wrote:

              4 - use string.Empty over "", as it's more efficient

              Even better: assign null to the reference. That way if you try to use the value without assigning it a usable value, you will get a null reference exception instead of a cryptic error from the database. Alternatively, add a default case in the switch, where you throw an appropriate exception. That way you don't have to assign anything to the variable before the switch statement, as the compiler knows that the variable always has a value when you exit the switch.

              --- single minded; short sighted; long gone;

              1 Reply Last reply
              0
              • C Christian Graus

                1 - all your code is ripe for SQL injection attacks 2 - As has been said, you should never have DB code in your presentation layer 3 - As has been said, why catch exceptions and do nothing ? 4 - use string.Empty over "", as it's more efficient 5 - Give your controls meaningful names. When someone else looks at the code, how do they know which button was button1 ?

                Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                I Offline
                I Offline
                Ibuprofen
                wrote on last edited by
                #8

                1. People have said this, but I still don't understand what they mean. 2. Why should you never have DB code in your presentation layer? 3. Actually, that is my most recent problem, the exception is catching an error, every value is updating the table, yet the exception err, is throwing "cannot find table 0" 4. I didn't even know you could do that, you would think the people that I work with that have degree's would code the write way, I guess not! 5. Eh, button1, I normaly do, this page actually only has one button it. I just hadn't gotten to renameing it. Here is the most recent of my button1click, private void Button1_Click(object sender, System.EventArgs e) { bool bNoError =true; OleDbConnection con = new OleDbConnection(strConnection2); string strSQL=""; DataSet ds = new DataSet(); CUsers user =new CUsers(); user=(CUsers)Session["SessionUser"]; switch(user.Role) { case "TL": //string strStatus=""; if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } else { TicketClosedBy.Text=""; } strSQL="UPDATE UserFeedback set [TLComment]='"+TLComment.Text+"', [TLwho]='"+TLwho.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"', [NeedAction]='"+NeedAction.SelectedValue+"' WHERE autoNum="+TicketNum.Text; break; case "CP": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [CPComment]='"+CPComment.Text+"', [CPwho]='"+CPwho.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+TicketNum.Text; break; case "ORA": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [ORAComments]='"+ORAComments.Text+"', [ORAwho]='"+ORAwho.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+TicketNum.Text; break; case "DMO": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [DMComments]='"+DMComments.Text+"', [DMwho]='"+DMwho.T

                I 1 Reply Last reply
                0
                • C Christian Graus

                  This was surely not production code ? The giveaway is that the button is called Button1....

                  Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                  I Offline
                  I Offline
                  Ibuprofen
                  wrote on last edited by
                  #9

                  It wont be "production" for another 6 months. Again, though I bulid data collection websites for the govt. I have trained users, and on a secure server, that only my users have access too. The actual website, will be used for about 2 months, and then, never used again, and I will start another project.

                  1 Reply Last reply
                  0
                  • I Ibuprofen

                    1. People have said this, but I still don't understand what they mean. 2. Why should you never have DB code in your presentation layer? 3. Actually, that is my most recent problem, the exception is catching an error, every value is updating the table, yet the exception err, is throwing "cannot find table 0" 4. I didn't even know you could do that, you would think the people that I work with that have degree's would code the write way, I guess not! 5. Eh, button1, I normaly do, this page actually only has one button it. I just hadn't gotten to renameing it. Here is the most recent of my button1click, private void Button1_Click(object sender, System.EventArgs e) { bool bNoError =true; OleDbConnection con = new OleDbConnection(strConnection2); string strSQL=""; DataSet ds = new DataSet(); CUsers user =new CUsers(); user=(CUsers)Session["SessionUser"]; switch(user.Role) { case "TL": //string strStatus=""; if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } else { TicketClosedBy.Text=""; } strSQL="UPDATE UserFeedback set [TLComment]='"+TLComment.Text+"', [TLwho]='"+TLwho.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"', [NeedAction]='"+NeedAction.SelectedValue+"' WHERE autoNum="+TicketNum.Text; break; case "CP": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [CPComment]='"+CPComment.Text+"', [CPwho]='"+CPwho.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+TicketNum.Text; break; case "ORA": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [ORAComments]='"+ORAComments.Text+"', [ORAwho]='"+ORAwho.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+TicketNum.Text; break; case "DMO": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [DMComments]='"+DMComments.Text+"', [DMwho]='"+DMwho.T

                    I Offline
                    I Offline
                    Ibuprofen
                    wrote on last edited by
                    #10

                    Cannot find table 0. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IndexOutOfRangeException: Cannot find table 0. Source Error: Line 440: Line 441: da.Fill(ds); Line 442: DataTable mytable =ds.Tables[0]; Line 443: DataRow myRow ; Line 444: myRow = mytable.Rows[0]; Source File: c:\dimhrs\helpdesk\userfeedback.aspx.cs Line: 442 Stack Trace: [IndexOutOfRangeException: Cannot find table 0.] System.Data.DataTableCollection.get_Item(Int32 index) DIMHRS.HelpDesk.UserFeedBack.Button1_Click(Object sender, EventArgs e) in c:\dimhrs\helpdesk\userfeedback.aspx.cs:442 System.Web.UI.WebControls.Button.OnClick(EventArgs e) System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) System.Web.UI.Page.ProcessRequestMain()

                    I 1 Reply Last reply
                    0
                    • I Ibuprofen

                      Cannot find table 0. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IndexOutOfRangeException: Cannot find table 0. Source Error: Line 440: Line 441: da.Fill(ds); Line 442: DataTable mytable =ds.Tables[0]; Line 443: DataRow myRow ; Line 444: myRow = mytable.Rows[0]; Source File: c:\dimhrs\helpdesk\userfeedback.aspx.cs Line: 442 Stack Trace: [IndexOutOfRangeException: Cannot find table 0.] System.Data.DataTableCollection.get_Item(Int32 index) DIMHRS.HelpDesk.UserFeedBack.Button1_Click(Object sender, EventArgs e) in c:\dimhrs\helpdesk\userfeedback.aspx.cs:442 System.Web.UI.WebControls.Button.OnClick(EventArgs e) System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) System.Web.UI.Page.ProcessRequestMain()

                      I Offline
                      I Offline
                      Ibuprofen
                      wrote on last edited by
                      #11

                      I rewrote the try, and also put in something to catch the Handle the Error. private void UpdateFeedback_Click(object sender, System.EventArgs e) { bool bNoError =true; OleDbConnection con = new OleDbConnection(strConnection2); string strSQL=""; DataSet ds = new DataSet(); CUsers user =new CUsers(); user=(CUsers)Session["SessionUser"]; switch(user.Role) { case "TL": //string strStatus=""; if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } else { TicketClosedBy.Text=""; } strSQL="UPDATE UserFeedback set [TLComment]='"+TLComment.Text+"', [TLwho]='"+TLwho.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"', [NeedAction]='"+NeedAction.SelectedValue+"' WHERE autoNum="+TicketNum.Text; break; case "CP": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [CPComment]='"+CPComment.Text+"', [CPwho]='"+CPwho.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+TicketNum.Text; break; case "ORA": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [ORAComments]='"+ORAComments.Text+"', [ORAwho]='"+ORAwho.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+TicketNum.Text; break; case "DMO": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [DMComments]='"+DMComments.Text+"', [DMwho]='"+DMwho.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+TicketNum.Text; break; case "User": if(TicketStatus.SelectedValue=="Closed") { string strStatus="Closed"; TicketClosedBy.Text = strStatus; } strSQL="UPDATE UserFeedback set [Comments]='"+Comments.Text+"', [TicketStatus]='"+TicketStatus.SelectedValue+"', [TicketClosedBy]='"+TicketClosedBy.Text+"' WHERE autoNum="+TicketNum.Text; break; } try { OleD

                      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