📄 新建 文本文档.txt
字号:
namespace login
{
public partial class addstore : Form
{
SqlDataAdapter sqlDataAdapter1;
//存取数据库的主要类
SqlCommand sqlCommand1;
//SQL语句处理的类
SqlConnection sqlConnection1;
// 表示是否处于插入新记录的状态
private bool bNewRecord = false;
DataSet dataSet1;
// 获取所有客户的ID
private void GetCustomID()
{
SqlDataReader sdr;
sqlConnection1.Open(); // 打开连接
sdr = sqlCommand1.ExecuteReader(CommandBehavior.CloseConnection);
cbxID.Items.Clear();
while (sdr.Read())
{
// 把客户ID插入到组合框控件中
cbxID.Items.Add(sdr.GetValue(0));
}
sdr.Close(); // 关闭SqlDataReader对象和数据库连接
cbxID.SelectedIndex = 0;
}
public addstore()
{
InitializeComponent();
// Windows 安全登录机制
String sConnString = "Data Source=localhost;Initial Catalog=WZGL_20052070;Integrated Security=True";
//SQL语句
String sSQL = "SELECT * FROM outstore";
//创建一个数据库连接对象
sqlConnection1 = new SqlConnection(sConnString);
sqlCommand1 = new SqlCommand(sSQL, sqlConnection1);
//创建一个SqlDataAdapter对象
sqlDataAdapter1 = new SqlDataAdapter(sSQL, sqlConnection1);
// 创建一个DataSet对象
dataSet1 = new DataSet();
sqlDataAdapter1.Fill(dataSet1, "admin");
dataGridView1.DataSource = dataSet1.Tables["admin"];
sqlCommand1.CommandText = "SELECT pName FROM room order by pName";
GetCustomID();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -