Power Shell调用c#读取sqlserver数据
$server = "192.168.255.1" $uid = "sa" $db="xx" $pwd="a@123456" $SqlConnection = New-Object System.Data.SqlClient.SqlConnection $CnnString ="Server = $server; Database = $db;User Id = $uid; Password = $pwd" $SqlConnection.ConnectionString = $CnnString $CC = $SqlConnection.CreateCommand(); if (-not ($SqlConnection.State -like "Open")) { $SqlConnection.Open() } $cc.CommandText=" select top(5) ICode from tblProduct " $list = $cc.ExecuteReader() while($list.Read()){ [System.Console]::WriteLine($list["ICode"]) } $SqlConnection.Close(); [System.Diagnostics.Process]::Start("chrome.exe","192.168.255.1")