WinF窗体,读取数据的时候突然弹出窗体。
namespace 省市选择2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
/*
//测试代码:执行这段代码的情况下是可以吧 tom这个值添加到 comboBox1中的。
People p1 = new People();
p1.name = "tom";
p1.age = 25;
comboBox1.Items.Add(p1.name);
*/
using (SqlConnection conn = new SqlConnection("Data source=FAN-VAIO;Initial catalog=sales;integrated security=true"))
{
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "select * from promary";
//当执行到这段代码的时候就弹出Form1窗体了。后面的代码完全没执行,请问这是为什么?
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
Province pv = new Province();