Trying to select row clicked on a datagridview after after the refresh sql query ?

spooke2k

Member
Joined
Feb 6, 2014
Messages
13
Programming Experience
1-3
Dim ActUser As String
Dim Hitme As String
Dim sql As String
Dim intResponse As Integer
Dim sqlupdate As String
Dim con1 As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data source ='" & dbPath1 & "'; Jet OLEDB:database password=123")






intResponse = MsgBox("Do You want to Assign this job to yourself" _
, vbYesNo + vbQuestion + vbDefaultButton2, _
"Current Task")
If intResponse = vbYes Then
TextBox1.Text = dgv2.CurrentRow.Cells(0).Value.ToString
TextBox2.Text = dgv2.CurrentRow.Cells(1).Value.ToString
TextBox3.Text = dgv2.CurrentRow.Cells(2).Value.ToString
TextBox4.Text = dgv2.CurrentRow.Cells(3).Value.ToString
TextBox5.Text = dgv2.CurrentRow.Cells(4).Value.ToString
CheckBox2.Checked = dgv2.CurrentRow.Cells(5).Value.ToString
TextBox7.Text = dgv2.CurrentRow.Cells(6).Value.ToString


' sqlinsert = "INSERT INTO users(FirstName,) VALUES(@FirstName, @LastName, @Address, @City, @Zip, @Phone, @Email, @IDNum)"""
Hitme = DateTime.Now
ActUser = Login.txt_Username.Text
sqlupdate = "UPDATE DataImport SET DataImport.IssuedtoAgent = 1, DataImport.AgentIssuedtoo = '" & ActUser & "', DataImport.[Date Issued] = '" & Hitme & "' WHERE ((([DataImport].[SPM])=" & TextBox1.Text & "));"


Dim cmd As New OleDbCommand(sqlupdate, con1)


con1.Open()
cmd.ExecuteNonQuery()
con1.Close()
'
' Dim col As Integer = dgv2.FirstDisplayedCell.ColumnIndex
Dim row As Integer = dgv2.FirstDisplayedCell.RowIndex




sql = " SELECT DataImport.SPM, DataImport.Number, DataImport.TTM, DataImport.Touched, DataImport.DATE_IN_QUEUE, DataImport.IssuedtoAgent, DataImport.AgentIssuedtoo,DataImport.Completed FROM DataImport WHERE (((Left([DataImport]![Number],4))='" & Area.Text & "'));"


Dim adapter As New OleDbDataAdapter(sql, con1)


Dim dt As New DataTable("DataImport")
adapter.Fill(dt)


dgv2.DataSource = dt
' dgv2.Refresh()


dgv2.FirstDisplayedCell = dgv2.Item(col, row)
' dgv2.Rows(i).Selected = True


Else
MessageBox.Show("Read Only, " & GlobalVariables.UserName)
End If
 
to clarify sorry im trying to basically get the datagridview to send row data to the textbox then update sql query to say assigned and then reselect that same row in flex grid becuse it keeps setting first col sel and not the last selected row after the sql reload
 

Latest posts

Back
Top