powershell:form_sqlite_db_client
差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン前のリビジョン | |||
powershell:form_sqlite_db_client [2025/10/01 02:04] – mikoto | powershell:form_sqlite_db_client [2025/10/02 07:38] (現在) – mikoto | ||
---|---|---|---|
行 141: | 行 141: | ||
# フォームを表示 | # フォームを表示 | ||
[void]$form.ShowDialog() | [void]$form.ShowDialog() | ||
+ | </ | ||
+ | |||
+ | ===== 検索機能の実装 ===== | ||
+ | |||
+ | <code powershell> | ||
+ | # --- 検索用関数 --- | ||
+ | function searchRecords { | ||
+ | param ( | ||
+ | [System.Data.SQLite.SQLiteConnection]$connection, | ||
+ | [string]$table_name, | ||
+ | [string]$keyword | ||
+ | ) | ||
+ | |||
+ | $dataTable = New-Object System.Data.DataTable | ||
+ | $cmd = $connection.CreateCommand() | ||
+ | $cmd.CommandText = " | ||
+ | # $null = $cmd.Parameters.AddWithValue(" | ||
+ | |||
+ | $adapter = New-Object System.Data.SQLite.SQLiteDataAdapter($cmd) | ||
+ | $adapter.Fill($dataTable) | Out-Null | ||
+ | return $dataTable | ||
+ | } | ||
+ | |||
+ | # 検索ボタン | ||
+ | $btnSearch = New-Object System.Windows.Forms.Button | ||
+ | $btnSearch.Text = " | ||
+ | $btnSearch.Location = New-Object System.Drawing.Point(430, | ||
+ | |||
+ | # 検索ボタンクリックイベント | ||
+ | $btnSearch.Add_Click({ | ||
+ | if ([string]$tbListArea.SelectedItem -ne $null) { | ||
+ | $table_name = ([string]$tbListArea.SelectedItem).Trim() | ||
+ | $keyword = [string]$textSearch.Text | ||
+ | # $dataTable = searchRecords -connection $conn -table_name $table_name -keyword $keyword | ||
+ | $dataGrid.DataSource = $dataTable | ||
+ | $dataTable | Format-Table -AutoSize | ||
+ | } else { | ||
+ | Write-Host " | ||
+ | } | ||
+ | }) | ||
</ | </ |
powershell/form_sqlite_db_client.1759251886.txt.gz · 最終更新: 2025/10/01 02:04 by mikoto