Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror

Comment Re:yes, but... (Score 1) 210

PS is useless for MS SQL...


function sql-connect( [string] $connStr = "Data Source=PUT_SERVER_HERE; Initial Catalog=PUT_DATABASE_HERE; UID=PUT_USERID_HERE; PWD=PUT_PASSWORD_HERE;" )
{
        $Global:conn = new-Object System.Data.SqlClient.SqlConnection( $connStr )
        $conn.Open()
}

function sql-disconnect()
{
        $conn.Close()
}

function select-sql( [string] $sql )
{
        $cmd = new-Object System.Data.SqlClient.SqlCommand($sql, $conn);
        $rdr = [System.Data.SqlClient.SqlDataReader]$cmd.ExecuteReader();

        $datatable = new-Object System.Data.DataTable
        $datatable.Load($rdr)
        $rdr.Close()

        return $datatable
}

function execute-sql( [string] $sql )
{
        $cmd = new-Object System.Data.SqlClient.SqlCommand($sql, $conn);
        $retval = $cmd.ExecuteNonQuery();

        return $retval
}

Slashdot Top Deals

Is knowledge knowable? If not, how do we know that?

Working...