遇到这个问题,未能找到类型或命名空间名称“scsb”(是否缺少 using 指令或程序集引用?),请问怎么处理呢;
private void Form1_Load(object sender, EventArgs e)
{
SqlConnectionStringBuilder scsb = new SqlConnectionStringBuilder();
scsb.DataSource = "192.168.100.247";
scsb.Initial catalog = "WHmesinfo";
scsb.UserID = "sa";
scsb.Password = "whyy@2021";
SqlConnection sqlConnection1 = new SqlConnection(scsb.ToString());//创建数据库连接
sqlConnection1.Open();
SqlDataAdapter sda = new SqlDataAdapter();
DataSet ds = new DataSet();
DataTable dt = new DataTable();
try
{
sqlConnection1.Open();
MessageBox.Show("数据库连接成功!");
}
catch (Exception ex)
{
MessageBox.Show("数据库连接失败");
return;
}
//声明一个SQLcommand对象
SqlCommand sqlcmd = new SqlCommand("SELECT * FROM b_EquipmentInfo", sqlConnection1);
//执行查询语句
sda.SelectCommand = sqlcmd;
//调用DataAdapter对象的Fill()方法来填充数据集
sda.Fill(ds, "b_EquipmentInfo");
//绑定combobox的数据集
comboBox1.DataSource = ds.Tables["b_EquipmentInfo"];
//选定combobox显示的成员及将Name这一列显示在combobox中
comboBox1.DisplayMember = "Equipmentname";
//combobox的实际取值
comboBox1.ValueMember = "Equipmentcode";
}
}