-
Notifications
You must be signed in to change notification settings - Fork 1
rancomma/MdbCommand
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
README [Install Guide] 1. Check PSModulePath C:\PS>$env:PSModulePath -split ";" C:\Users\UserName\Documents\WindowsPowerShell\Modules C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ 2. Copy MdbCommand Folder C:\Users\UserName\Documents\WindowsPowerShell\Modules\MdbCommand if using 64bitOS: run with WOW64(32bit) powershell [MdbCommand Exsamples] C:\PS>ipmo MdbCommand C:\PS>Open-Mdb newsample.mdb -Create C:\PS>Invoke-Mdb 'Create Table table1 (a int not null constraint PK Primary Key, b varchar, c yesno)' C:\PS>invoke-mdb 'create table table2 (ID counter not null primary key, a int, b int)' C:\PS>invoke-mdb @' create table table3 ( col1 string(5), col2 string(5), a int, constraint PK_table3 primary key (col1, col2) ) '@ C:\PS>Get-Mdb DatabaseName State Transaction DataSource ------------ ----- ----------- ---------- main Open No C:\scripts\ps1\newsample.mdb C:\PS>Get-MdbTable TableName TableType Description --------- --------- ----------- table1 TABLE table2 TABLE table3 TABLE C:\PS>Get-MdbColumn -TableName table1|ft -auto TableName Pos ColumnName DataType AliasType Size NotNull Default PKey AutoInc --------- --- ---------- -------- --------- ---- ------- ------- ---- ------- table1 1 a INTEGER int YES YES table1 2 b VARCHAR string 255 table1 3 c BIT yesno YES C:\PS>Get-MdbIndex |ft -auto TableName IndexName Primary Unique Position ColumnName Collation --------- --------- ------- ------ -------- ---------- --------- table1 PK YES YES 1 a ASC table2 Index_7BC68A99_2CED_49DE YES YES 1 ID ASC table3 PK_table3 YES YES 1 col1 ASC table3 PK_table3 YES YES 2 col2 ASC C:\PS>$list = new-object collections.arraylist C:\PS>$list.add(@(1,'colb1', $true)) C:\PS>$list.add(@(2,'colb2', $false)) C:\PS>$list.add(@(3,'colb3', $true)) C:\PS>Invoke-MdbBatch 'Insert Into table1 (a, b, c) Values (?, ?, ?)' $list C:\PS>${MdbCommand.BatchTotalRecordsAffected} 3 C:\PS>Add-MdbQuery InsertTable1 'Insert Into Table1 (a, b, c) Values (?, ?, ?)' C:\PS>Get-MdbQuery | ft -wrap QueryName QueryType SQL --------- --------- --- InsertTable1 ACTION INSERT INTO Table1 ( a, b, c ) C:\PS>Invoke-MdbQuery InsertTable1 -Value 4,'colb4',$false C:\PS>Invoke-Mdb 'Select a, b, c From table1 Where a > ?' 1 | ft -auto a b c - - - 2 colb2 False 3 colb3 True 4 colb4 False C:\PS>try >> { >> Start-MdbTransaction >> >> Invoke-Mdb "Update table1 Set b = 'colb_change' Where a = 1" >> >> # processing >> >> Complete-MdbTransaction >> } >> catch >> { >> Write-Warning "$_" >> Undo-MdbTransaction >> } C:\PS>Start-MdbConsole mdb> select * from table1 ...> / a b c - - - 1 colb1 True 2 colb2 False 3 colb3 True 4 colb4 False mdb> .show autosize : on echo : off headers : on nullvalue : "" width : wrap : on mdb> mdb> .help .autosize ON|OFF Like Format-Table AutoSize parameter .begin Start transaction .columns ?TABLE? List columns .commit Commit transaction .databases Show database Info .echo ON|OFF Turn command echo on or off .exit Exit this console .headers ON|OFF Turn display of headers on or off .help Show this message .indices ?T? ?C? ?I? List indices .nullvalue STRING Print STRING in place of NULL values .quit Exit this console .rollback Rollback transaction .show Show the current values for various settings .tables ?TABLE? List tables .views ?VIEW? List querys and procedures .width NUM1 NUM2 ... Set column widths (If ".width" Then clear widths) .wrap ON|OFF Like Format-Table Wrap parameter ; or / or GO Enter SQL statements terminated mdb> mdb> .quit C:\PS> C:\PS>Use-MdbAliasCommand -Prefix mdb- C:\PS>get-alias mdb-* CommandType Name Definition ----------- ---- ---------- Alias mdb-begin Start-MdbTransaction Alias mdb-close Close-Mdb Alias mdb-columns Get-MdbColumn ..................................... C:\PS>Use-MdbDotCommand C:\PS>get-alias .* CommandType Name Definition ----------- ---- ---------- Alias .begin Start-MdbTransaction Alias .close Close-Mdb Alias .columns Get-MdbColumn Alias .commit Complete-MdbTransaction Alias .console Start-MdbConsole ..................................... C:\PS>Close-Mdb C:\PS>.mdb sample1.mdb C:\PS>.databases C:\PS>.columns C:\PS>.querys C:\PS>.execute 'select * from table1' C:\PS>.quit
About
powershell ms mdb file automation command.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published