VB.Net DataGridView - Update

I have a windows form that I added a datagridview.  I am able to make update to one of the column that I had allowed users to make update.  However, when the cell for that particular row  is updated, I want it to update the "Modified_date" column with current date/time.

Anyone know how this can be done?
holemaniaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CodeCruiserCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
holemaniaAuthor Commented:
Thanks.  I will take a look and see how I can incorporate that with my current code.

Dim myDA As SqlDataAdapter
Dim myDT as DataTable 

Sub Query()
	Dim con As SqlConnection = New SqlConnection("Data Source=SVR;persist security info=False;initial catalog=SANDDB1;UID=SandBoxUser;PWD=SandDB01;")
        Dim cmd As SqlCommand = New SqlCommand("SELECT DISTINCT TRANS_ID, ITEM_ID, COMPLETE, MODIFIED_DATE FROM ITEM_DETAIL ", con)

        con.Open()

        myDA = New SqlDataAdapter(cmd)

        Dim builder As New SqlCommandBuilder(myDA)
        myDA.UpdateCommand = builder.GetUpdateCommand()

        myDT = New DataTable()

        myDA.Fill(myDT)



        'ALTERNATE COLOR
        Me.dgLookup.RowsDefaultCellStyle.BackColor = Color.White
        Me.dgLookup.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGray


        dgLookup.DataSource = myDT

        'COLUMN
        Me.dgLookUP.Columns("TRANS_ID").Visible = False
        Me.dgLookUP.Columns("ITEM_ID").Width = 100
        Me.dgLookUP.Columns("COMPLETE").Width = 150
        Me.dgLookUP.Columns("MODIFIED_DATE").Width = 50
  

        Try
           If dgLookUP.Rows.Count = 0 Then
              con.Close()
              con = Nothing
              Exit Sub

              End If

           Catch ex As Exception
              MsgBox(ex.Message)
           End Try


         con.Close()
         con = Nothing
End Sub

Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
       Try
	  myDA.Update(myDT)
       Catch
          MsgBox(ex.Message)
       End Try
End Sub

Open in new window


I am basically allowing person to update the "Complete" cells and then automatically update the Modified_date column with today's date.
0
holemaniaAuthor Commented:
Thank  you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.