using System.Data.SqlClient;
SqlConnection conn = new SqlConnection();
string connectionString="server=.;database=Sql;uid=sa; pwd=123456";
conn.ConnectionString = connectionString;
conn.open();
string sqlStr = "SELECT * FROM table1";
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = sqlStr;
cmd.CommandType = CommandType.Text;
int i = Convert.ToInt32(cmd.ExecuteNonQuery());
Console.Write("共有" + i.ToString() + "條資料");
conn.Close();
using System.Data.SqlClient;
SqlConnection conn = new SqlConnection();
string connectionString="server=.;database=Sql;uid=sa; pwd=123456";
conn.ConnectionString = connectionString;
conn.open();
string sqlStr = "SELECT * FROM table1";
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = sqlStr;
cmd.CommandType = CommandType.Text;
int i = Convert.ToInt32(cmd.ExecuteNonQuery());
Console.Write("共有" + i.ToString() + "條資料");
conn.Close();