using namespace System.Data.sqlclient
SqlConnection con = new SqlConnection("data source=
server_name;initial catelog=database_name;
integrated security=true_or_false/*(是否用Windows安全认证)*/;user id=sa;password=*****/*如果用Windows的安全认证就不用写了*/");
SqlCommand com = new SqlCommand();
com.Connection = con;
com.Connection.Open();
com.CommandText="select * from table_name where XX=@a"
com.Parameters["@a"].Value = YY;
SqlDataReader rd = con.ExecuteReader();
where(rd.read())
{
Console.WriteLine(re.GetValue(0/*列值*/).ToString()+re.GetString(1/*列值*/));
}
rd.Close();
con.Close();
[此贴子已经被作者于2006-6-21 14:38:17编辑过]