ASP.NET连接数据库
连接Access:
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=绝对路径";//+Server.MapPath("相对路径");
连接SqlServer
SqlConnection conn1 = new SqlConnection();
conn1.ConnectionString = "Data Source=服务器名;uid=用户名;pwd=密码;database=数据库名;integrated security=true";
conn.Open();//开启连接
conn.Close();//关闭连接
操作数据库
OleDbCommand comm = new OleDbCommand();
comm.CommandText = "数据库操作命今";
comm.Connection = conn;
comm.ExecuteNonQuery();