返回顶部

收藏

Powershell连接Access数据库

更多

Powershell连接Access数据库

[Shell/批处理]代码

$objOleDbConnection = New-Object "System.Data.OleDb.OleDbConnection"
$objOleDbCommand = New-Object "System.Data.OleDb.OleDbCommand"
$objOleDbAdapter = New-Object "System.Data.OleDb.OleDbDataAdapter"
$objDataTable = New-Object "System.Data.DataTable"

$objOleDbConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Script\PowerShell-Example.mdb;"
$objOleDbConnection.Open()

$objOleDbConnection.State

$objOleDbCommand.Connection = $objOleDbConnection
$objOleDbCommand.CommandText = "SELECT * FROM [Example]"

##set the Adapter object
$objOleDbAdapter.SelectCommand = $objOleDbCommand

##fill the objDataTable object with the results
$objOleDbAdapter.Fill($objDataTable)

##To display the “raw” contents, just enter
$objDataTable

## close the connection 
$objOleDbConnection.Close()

标签:Shell/批处理

收藏

0人收藏

支持

0

反对

0

»更多 您可能感兴趣的代码
  1. 2015-09-27 14:51:0921点游戏 by 司马
  2. 2015-09-17 16:46:17PPP连接检查 by xuleaper
  3. 2015-09-10 11:45:20Shell文件删除自身 by grant
  4. 2015-09-10 09:42:34简单的防火墙脚本 by starstroll
  5. 2015-09-09 10:51:01使用文件作为数据库 by Echo
  6. 2015-09-07 13:24:58取一个目录下所有的文件的扩展名 by loking
  7. 2015-09-06 10:16:21Powershell操作Word by xuleaper
  8. 2015-09-04 19:58:30又一个井字游戏 by 好剑
  9. 2015-09-04 17:36:54用Shell以一个文件夹的框架在另一个目录创建文件夹 by 屁屁果
  10. 2015-09-03 21:44:57Shell创建文件夹 by 二糊
  11. 2019-06-17 21:18:10PHP+jQuery.photoClip.js图片裁剪上传实例 by 素材火官网

发表评论