4 Replies - 372 Views - Last Post: 01 September 2013 - 05:32 AM Rate Topic: -----

#1 ewankosau  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 31-March 13

vb.net and sql flagging

Posted 01 September 2013 - 03:19 AM

please help im newbie in programming im using vb.net and sql

i want to highlight with color cyan the value (1) for deletion i dont want to delete data instead i use to highlight it as way of deletion in vb.net when i stop and re run again the program the highlighted data was unhighlighted

this is my code:

Private Sub dgvDoctorsList_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvDoctorsList.CellDoubleClick

If MessageBox.Show("Are you sure want to delete this data ?", "CONFIRMATION", MessageBoxButtons.YesNo, MessageBoxIcon.Information) = Windows.Forms.DialogResult.Yes Then

    Dim objCmd As New SqlCommand()
    Using con As New SqlConnection("server=ACHACOSOFAMILY;database=jjasgh;integrated security=true")
        objCmd.Connection = con
        con.Open()

        For Each objRow As DataGridViewRow In dgvDoctorsList.SelectedRows
            objCmd.CommandText = "Update tbl_Doctor SET Remarks=1 where License_no=@license"

            objCmd.Parameters.AddWithValue("@license", dgvDoctorsList.CurrentRow.Cells(0).Value)
            objCmd.ExecuteNonQuery()
            objRow.DefaultCellStyle.BackColor = Color.Cyan

        Next
    End Using

    con.Close()


 End sub

can anyone help me in this kind of program thanks for consideration thanks in advance

Attached image(s)

  • Attached Image

This post has been edited by andrewsw: 01 September 2013 - 03:33 AM
Reason for edit:: Please use CODE tags


Is This A Good Question/Topic? 0
  • +

Replies To: vb.net and sql flagging

#2 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3812
  • View blog
  • Posts: 13,522
  • Joined: 12-December 12

Re: vb.net and sql flagging

Posted 01 September 2013 - 04:00 AM

You can use the CellFormatting event of the DataGridView to achieve the equivalent of Conditional Formatting. (There is an example in the linked page.) If Remarks is not already a column in the DGV you will probably want to include it (perhaps hidden).

Quote

The CellFormatting event occurs every time each cell is painted, so you should avoid lengthy processing when handling this event.

This post has been edited by andrewsw: 01 September 2013 - 04:02 AM

Was This Post Helpful? 0
  • +
  • -

#3 ewankosau  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 31-March 13

Re: vb.net and sql flagging

Posted 01 September 2013 - 04:13 AM

sir i want to use highlight for deletion but deletion not means its already deleted perhaps highlighting the data in gridview/database means delete but the data is still in the database and also in the datagridview but it is highlighted
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3812
  • View blog
  • Posts: 13,522
  • Joined: 12-December 12

Re: vb.net and sql flagging

Posted 01 September 2013 - 05:02 AM

View Postewankosau, on 01 September 2013 - 11:13 AM, said:

sir i want to use highlight for deletion but deletion not means its already deleted perhaps highlighting the data in gridview/database means delete but the data is still in the database and also in the datagridview but it is highlighted

I cannot decipher this. Please form proper sentences.
Was This Post Helpful? 0
  • +
  • -

#5 ewankosau  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 31-March 13

Re: vb.net and sql flagging

Posted 01 September 2013 - 05:32 AM

sorry sir wat i need is . highlight the delete data with a value (1) . if i close and run again the program i want the highlighted data is still in the gridview

i mean the deleted data is still in the gridview and also in database but these data is highlighted
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1