hi guys i need help .... i have a value witch import into datagridview...on the datagridview... it display 4 column named , date, status,position,and time .... under column status,position,time and date it have 5 rows... i want to get the values under column time and transfer it to the TextBox once i click the button named "transfer",what is the proper code should i code??
this was my code for selecting value from database into datagridview which is displaying the column date,status,position,and time
Dim arr(100) As String
Try
conn.Open()
query = New MySqlCommand("SELECT No,Name,date,status,position,time From
cash_table WHERE No Like '%" & txtID.Text & "%'", conn)
dr = query.ExecuteReader()
While dr.Read
txtName.Text = dr.GetString("Name")
txtPosition.Text = dr.GetString("position")
If dr.HasRows Then
Do While dr.Read
arr(0) = dr.Item("date")
arr(1) = dr.Item("status")
arr(2) = dr.Item("position")
arr(2) = dr.Item("time")
DataGridView1.Rows.Add(arr)
Loop
query.ExecuteNonQuery()
Else
MsgBox("No Records Found!", MsgBoxStyle.Information, "Search")
End If
End While
Catch ex As Exception
MsgBox(ex.ToString)
Finally
dr.Close()
conn.Close()
End Try
Try
If txtID.Text = "" Then
DataGridView1.Rows.Clear()
End If
Catch ex As Exception
MsgBox("contact your administrator")
End Try
What I have tried:
iv tried this code but i think it is not the appropriate one
conn.Open()
query = New MySqlCommand("UPDATE attendancetable SET No=@TextBox1.Text,Name=@TextBox2.Text,month=@TextBox3.Text,days=@TextBox4.Text,year=@TextBox5.Text,total=@TextBox6.Text", conn)
query.Parameters.AddWithValue("No", txtID.Text)
query.Parameters.AddWithValue("Name", txtName.Text)
query.Parameters.AddWithValue("month", TextBox2.Text)
query.Parameters.AddWithValue("days", txtPosition.Text)
query.Parameters.AddWithValue("year", TextBox3.Text)
query.Parameters.AddWithValue("total", TextBox4.Text)
query.ExecuteNonQuery()
conn.Close()
End Sub