private SQLiteConnection m;
private SQLiteConnection m1;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string dbPath = @"D:\历年高考分数.db";
string sq = @"Data Source=" + dbPath;
m = new SQLiteConnection(sq);
m.Open();
SQLiteDataAdapter mAdapter = new SQLiteDataAdapter("select province from combox1值", m);
DataSet ds = new DataSet();
mAdapter.Fill(ds);
DataTable dt = ds.Tables[0];
comboBox1.DataSource = dt;
comboBox1.ValueMember = "province";
comboBox1.SelectedIndex = 0;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string dbPath1 = @"D:\历年高考分数.db";
string sq1 = @"Data Source=" + dbPath1;
m1 = new SQLiteConnection(sq1);
m1.Open();
SQLiteDataAdapter mAdapter1 = new SQLiteDataAdapter("select from combox2值", m1);
DataSet ds1 = new DataSet();
mAdapter1.Fill(ds1);
DataTable dt1 = ds1.Tables[0];
comboBox2.DataSource = dt1;
//comboBox2.ValueMember = "province";
comboBox2.SelectedIndex = 0;
//comboBox3.DisplayMember = "列标题";
// m1.Close();
if (comboBox1.SelectedIndex == 0)
{
comboBox2.Items.Clear();
comboBox2.ValueMember = "四川";
}
else if (comboBox1.SelectedIndex == 1)
{
comboBox2.Items.Clear();
comboBox2.ValueMember = "江苏";
}
else if (comboBox1.SelectedIndex == 2)
{
comboBox2.Items.Clear();
comboBox2.ValueMember = "广州";
}
else if (comboBox1.SelectedIndex == 3)
{
comboBox2.Items.Clear();
comboBox2.ValueMember = "直辖市";
}
m1.Close();
}
SQLiteDataAdapter mAdapter1 = new SQLiteDataAdapter("select from combox2值", m1);
->
SQLiteDataAdapter mAdapter1 = new SQLiteDataAdapter("select 这里写字段名 from combox2值", m1);