Long story as short as I can. I have a CSV with Name,Card. I want to have a textbox that you input a card # and populate the result in the datagridview from the CSV contents, and continue to append to it. Basically people will input their card number to "check in" to a meeting, this will append to the datagridview until the end then I can export to another CSV. I have all this working, probably the wrong way, but cannot export the results to to a CSV. Now I know I have to "convert" the inputted CSV to a Datatable and thats where I am confused.
This is basically what I have so far:
Code: Select all
$form1_Load = {
$dataGridView1.ColumnCount = 2
$dataGridView1.ColumnHeadersVisible = $true
$dataGridView1.Columns[0].Name = "Name"
$dataGridView1.Columns[1].Name = "Card1"
}
$buttonSubmit_Click = {
$Global:cardnumber = $textboxScandata.Text
$importstatement = Import-Csv $UsersDB | where { $_.Card1 -eq $cardnumber }
If ($importstatement)
{
$importstatement | foreach {
$datagridview1.Rows.add($_.Name, $_.Card1)
}
}
}
This works just fine but I cannot export to a csv. I know running the Import-CSV each time the submit button is press is not the right way to do it but I don't know how to write it to filter by the card number specified then append that to the datagridview. Each way I try it re-creates the datagridview with only the last record I searched for.
Can someone bump me in the right direction or give an example to follow.
Thanks,
Scott