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. Updation problem

Updation problem

Scheduled Pinned Locked Moved ASP.NET
helpquestiongraphicsannouncement
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
    n_gchaitra
    wrote on last edited by
    #1

    What is error in this code? When I click btnsave button, though it is giving the message 'Project has been started', the data is not getting updated. Protected Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click start(txtpno.Text.Trim()) End Sub Function start(ByVal pno As String) Dim sqlstr1 As String Dim dr As SqlClient.SqlDataReader sqlstr1 = "update D_task_det set str_date='" & Now.Date() & "',status='In_Progress' where pno='" & pno & "'and flag='0'and task='" & lbltask.Text.Trim() & "' and status='Pending'" Try If dbconn.State <> ConnectionState.Open Then dbconn.Open() End If Dim sqlcomm1 As New SqlClient.SqlCommand(sqlstr1, dbconn) sqlcomm1.ExecuteNonQuery() dbconn.Close() lblmsg.ForeColor = Drawing.Color.DarkGreen lblmsg.Text = "Project has been started." tbentervalue.Visible = False tbtelescopic.Visible = False tbpto.Visible = False tbsystem.Visible = False tbaccessories.Visible = False tbvalves.Visible = False tbpumps.Visible = False tbtipper.Visible = False tbentervalue.Visible = False tboth.Visible = False lbltask.Visible = False ' clear() newproject() Catch ex As Exception lblmsg.Text = "Transaction failed." ' + ex.ToString() dbconn.Close() End Try End Function

    Chaitra N

    C 1 Reply Last reply
    0
    • N n_gchaitra

      What is error in this code? When I click btnsave button, though it is giving the message 'Project has been started', the data is not getting updated. Protected Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click start(txtpno.Text.Trim()) End Sub Function start(ByVal pno As String) Dim sqlstr1 As String Dim dr As SqlClient.SqlDataReader sqlstr1 = "update D_task_det set str_date='" & Now.Date() & "',status='In_Progress' where pno='" & pno & "'and flag='0'and task='" & lbltask.Text.Trim() & "' and status='Pending'" Try If dbconn.State <> ConnectionState.Open Then dbconn.Open() End If Dim sqlcomm1 As New SqlClient.SqlCommand(sqlstr1, dbconn) sqlcomm1.ExecuteNonQuery() dbconn.Close() lblmsg.ForeColor = Drawing.Color.DarkGreen lblmsg.Text = "Project has been started." tbentervalue.Visible = False tbtelescopic.Visible = False tbpto.Visible = False tbsystem.Visible = False tbaccessories.Visible = False tbvalves.Visible = False tbpumps.Visible = False tbtipper.Visible = False tbentervalue.Visible = False tboth.Visible = False lbltask.Visible = False ' clear() newproject() Catch ex As Exception lblmsg.Text = "Transaction failed." ' + ex.ToString() dbconn.Close() End Try End Function

      Chaitra N

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

      You should read up on SQL injection attacks. Nowhere does your code check to see if the update command actually updated any records, I recommend stepping through to see what the sQL is, and running the same SQL in query analyser, to see if it actually finds any records to update.

      Christian Graus - Microsoft MVP - C++ "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 )

      N 1 Reply Last reply
      0
      • C Christian Graus

        You should read up on SQL injection attacks. Nowhere does your code check to see if the update command actually updated any records, I recommend stepping through to see what the sQL is, and running the same SQL in query analyser, to see if it actually finds any records to update.

        Christian Graus - Microsoft MVP - C++ "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 )

        N Offline
        N Offline
        n_gchaitra
        wrote on last edited by
        #3

        When I run the statement in query analyzer, it does work. And how to read up on SQL injection attacks

        Chaitra N

        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