C# 编写一个 功能简单的教师工资管理系统 要求连接access数据库或者sql...
发布网友
发布时间:2024-10-02 12:52
我来回答
共1个回答
热心网友
时间:2024-10-04 00:49
查询:
SqlConnection con = new SqlConnection();
con.ConnectionString = "server=服务器地址;database=数据库名;uid=用户名;pwd=密码";
DataSet dataSet = new DataSet();
string sql = "select * from 数据库表名";
SqlDataAdapter adapter = new SqlDataAdapter(sql, con);
adapter.Fill(dataSet, "Teacher");
dataGridView1.DataSource = dataSet.Tables["Teacher"];
修改,增删改
SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
adapter.Update(dataSet,"Teacher");
PS:
adapter,dataSet应该是全局变量