日期:2014-05-17 浏览次数:20883 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace F6
{
public partial class UpdateUsers : Form
{
private System.Data.DataTable DT = new System.Data.DataTable();
private SqlDataAdapter SDA = new SqlDataAdapter();
private SqlConnection conn = new SqlConnection();
public UpdateUsers()
{
InitializeComponent();
}
public DataTable selectDutys()
{
DT.Clear();
conn = new SqlConnection(SQLForF6.conStr);
conn.Open();
SqlCommand scSelectDutys = new SqlCommand("select dutyid,dutyname from dutys order by dutyid asc", conn);
SDA = new SqlDataAdapter(scSelectDutys);
SDA.Fill(DT);
conn.Close();
scSelectDutys.Dispose();
return DT;
}
private void UpdateUsers_Load(object sender, EventArgs e)
{
//在窗体load事件为下拉框绑定数据
selectDutyCombox.DataSource = null;
selectDutyCombox.DataSource = selectDutys();
selectDutyCombox.DisplayMember = "dutyname";
selectDutyCombox.ValueMember = "dutyid";
}
}
}
select dutyid,dutyname from dutys order by dutyid asc