天天看點

C#資料庫問題

string connection = "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind";

string sql = "select * from User";

public void Sqlconnection(string connection,string sql)

{

SqlConnection conn = new SqlConnection(connection);

conn.Open();

SqlCommand comm = new SqlCommand(sql, conn);

SqlDataReader read = comm.ExecuteReader();

while (read.Read())

{ }

read.Close();

conn.Close();

}