using System.Data;
using System.Data.SqlClient;
sql = "SELECT * FROM table";
string _connection = ConfigurationManager.ConnectionStrings["cn"].ConnectionString;
SqlConnection conn = new SqlConnection(_connection);
try {
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = sql;
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds);
}
catch (Exception) {
throw;
}
finally {
conn.Close();
}
沒有留言:
張貼留言