ado.net
ADO.NET的名称起源于ADO(ActiveX Data Objects),是一个COM组件库,用于在以往的Microsoft技术中访问数据。之所以使用ADO.NET名称,是因为Microsoft希望表明,这是在NET编程环境中优先使用的数据访问接口。--来自非常靠谱的百度百科
Connection 类
和数据库交互,必须连接它。连接帮助指明数据库服务器、数据库名字、用户名、密码,和连接数据库所需要的其它参数。Connection对象会被Command对象使用,这样就能够知道是在哪个数据源上面执行命令。
Command对象
成功与数据建立连接后,就可以用Command对象来执行、修改、插入、删除等命令
DataReader类
用于查询
string sql = "server=.;database=student;user=sa;pwd=123";
SqlConnection conn = new SqlConnection(sql);
SqlCommand cmd = conn.CreateCommand();
conn.open();
cmd.ExecuteReader();
cmd.ExecuteNonQuery();
conn.close();