Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Update Query Unable To Run Properly

$
0
0
Please tell me
I have write following code for updating data as well as listview. It do not generate any error. But not updated the records in database as well as in listview also. What changes must be in my code?



 Private Sub BtnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnUpdate.Click
        If TxtMRNNO.Text = "" Then
            MsgBox("Please enter MRN NO. ", MsgBoxStyle.Information, "Site Management System")
            TxtMRNNO.Focus()
            Exit Sub
        End If
        'blnAddFlag = False
        'blnEditFlag = True
        '  Call SetButtons(False)
        '"insert into MRN_DTL values(" & Val(TxtMRNNO.Text) & "," & Val(Trim(ListView1.Items(i).SubItems(0).Text)) & ",'" & ListView1.Items(i).SubItems(6).Text & "'," & Val(Trim(ListView1.Items(i).SubItems(2).Text)) & "," & Val(ListView1.Items(i).SubItems(4).Text) & "," & Val(ListView1.Items(i).SubItems(5).Text) & ")"
        Dim i As Integer
        Dim strUpdate As String
        strUpdate = "update MRN_DTL  set ITEM_CODE=" & Val(ListView1.Items(i).SubItems(6).Text) & ", REQQTY=" & Val(ListView1.Items(i).SubItems(2).Text) & ", AVQTY=" & Val(ListView1.Items(i).SubItems(4).Text) & ", ORDERQTY=" & Val(ListView1.Items(i).SubItems(5).Text) & " where MRN_NO=" & Val(TxtMRNNO.Text)
        cmd.CommandText = strUpdate
        cmd.CommandType = CommandType.Text
        cmd.Connection = con
        If con.State <> ConnectionState.Open Then
            con.Open()
        End If
        i = cmd.ExecuteNonQuery
        strUpdate = "Update MRN_HEADER set MRN_DATE='" & DTMRN.Value.Date & "',SITE_CODE=" & CmbSiteName.SelectedValue & " where MRN_NO=" & Val(TxtMRNNO.Text)
        cmd.CommandText = strUpdate
        cmd.CommandType = CommandType.Text
        cmd.Connection = con
        If con.State <> ConnectionState.Open Then
            con.Open()
        End If
        i = cmd.ExecuteNonQuery
        MsgBox(i & " Reocord Updated Suucessfully!", vbExclamation, "Site Management System")
        Call ClrAll()

    End Sub



Thank You

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>