在vs里怎么将我在label1里获得的大量数据传的数据库里啊??? 用C#怎么编写程序???
2个回答
展开全部
建立 DataGrid_User控件,从UserInfor表中获得数据显示在控件上,C#2008代码如下:
private void GetUserData()
{
OleDbDataAdapter dAdapter;
DataSet dSet;
string sqlStr = "select * from UserInfor order by UserNO" ;
OleDbConnection dbCon = DataAccess.newConnection();
try
{
dAdapter = new OleDbDataAdapter(sqlStr, dbCon);
dSet = new DataSet();
dAdapter.Fill(dSet, "UserTable");
this.DataGrid_User.DataSource = dSet.Tables["UserTable"];
}
catch (OleDbException ex)
{
MessageBox.Show("Error : " + ex.Message);
}
finally
{
dbCon.Close();
}
}
private void GetUserData()
{
OleDbDataAdapter dAdapter;
DataSet dSet;
string sqlStr = "select * from UserInfor order by UserNO" ;
OleDbConnection dbCon = DataAccess.newConnection();
try
{
dAdapter = new OleDbDataAdapter(sqlStr, dbCon);
dSet = new DataSet();
dAdapter.Fill(dSet, "UserTable");
this.DataGrid_User.DataSource = dSet.Tables["UserTable"];
}
catch (OleDbException ex)
{
MessageBox.Show("Error : " + ex.Message);
}
finally
{
dbCon.Close();
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询