Basically I am running the sql command:
and then populating a datagridview with all of the selected values from that SQL command and then putting the first cell into a variable using the code:
I am then running a second SQL command:
sql = "SELECT [Skill Set] FROM [Staff] WHERE [Name] = '" & staffname & "'"
and then using that command to populate a second datagridview. The problem is, when i populate the second datagridview, it populates it with the first SQL command's selected values as well as the 2nd SQL command's values. Does anyone know why it is doing this and how to fix it? Here is the full code.
Code:
sql = "SELECT [Name] FROM [Staff]"Code:
staffname = DataGridView2.Rows(0).Cells(0).Valuesql = "SELECT [Skill Set] FROM [Staff] WHERE [Name] = '" & staffname & "'"
and then using that command to populate a second datagridview. The problem is, when i populate the second datagridview, it populates it with the first SQL command's selected values as well as the 2nd SQL command's values. Does anyone know why it is doing this and how to fix it? Here is the full code.
Code:
cn.Open()
sql = "SELECT [Name] FROM [Staff]" 'selecting all names in order to schedule one by one.
Dim cmd As New OleDbCommand(sql, cn)
da = New OleDbDataAdapter(sql, cn)
da.Fill(ds, "Staff")
DataGridView2.DataSource = ds.Tables("Staff")
staffname = DataGridView2.Rows(0).Cells(0).Value 'schedule the first member of staff here.
cn.Close()
MsgBox(staffname)
sql = "SELECT [Skill Set] FROM [Staff] WHERE [Name] = '" & staffname & "'" 'selecting his skill set so knows who he can work with
cn.Open()
cmd = New OleDbCommand(sql, cn)
da = New OleDbDataAdapter(sql, cn)
da.Fill(ds, "Staff")
DataGridView3.DataSource = ds.Tables("Staff")
cn.Close()
cmd.Dispose()
skill = DataGridView3.Rows(0).Cells(0).Value ' put skillset into a variable
MsgBox(skill)