[c#]代码库
using System;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.IO.Compression;
using System.Text;
private DataSet GetDataSet(string paramValue)
{
using (SqlConnection sqlConn = new SqlConnection("Data Source=(local);Initial Catalog=msdb;Integrated Security=True;"))
{
try
{
SqlCommand sqlcomm = new SqlCommand();
using (SqlDataAdapter da = new SqlDataAdapter())
{
sqlcomm.Connection = sqlConn;
sqlConn.Open();
// This will be your input parameter and its value
sqlcomm.Parameters.AddWithValue("@job_name", paramValue);
// Name of stored procedure
sqlcomm.CommandText = "sp_help_job";
da.SelectCommand = sqlcomm;
da.SelectCommand.CommandType = CommandType.StoredProcedure;
DataSet ds = new DataSet();
da.Fill(ds);
sqlConn.Close();
return ds;
}
}
catch (Exception ex)
{
Console.WriteLine("SQL Error: " + ex.Message);
}
}
return null;
}
private void Form1_Load(object sender, EventArgs e)
{
DataSet ds = GetDataSet("Coverage");
DataTable dt = ds.Tables[1];
foreach (DataRow row in dt.Rows)
{
if ((string)row["subsystem"] == "SSIS")
{
MessageBox.Show((string)row["command"]);
}
}
}
by: 发表于:2017-12-27 10:08:47 顶(0) | 踩(0) 回复
??
回复评论