private void frmImport_Load(object sender, EventArgs e) { comboBox2.Items.Clear(); SqlConnection SqlConn = new SqlConnection("Data Source=10.100.1.6; Trusted_Connection=True;"); SqlConn.Open(); SqlCommand SqlCom = new SqlCommand(); SqlCom.Connection = SqlConn; SqlCom.CommandType = CommandType.StoredProcedure; SqlCom.CommandText = "sp_databases"; SqlDataReader SqlDR; SqlDR=SqlCom.ExecuteReader(); while (SqlDR.Read()) { comboBox1.Items.Add(SqlDR.GetString(0)); } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { comboBox2.Items.Clear(); SqlConnection SqlConn = new SqlConnection("Data Source=10.100.1.6; Initial Catalog=" +comboBox1.SelectedItem.ToString +";Trusted_Connection=True;"); SqlConn.Open(); SqlCommand SqlCom = new SqlCommand(); SqlCom.Connection = SqlConn; SqlCom.CommandType = CommandType.StoredProcedure; SqlCom.CommandText = "sp_tables"; SqlDataReader SqlDR; SqlDR = SqlCom.ExecuteReader(); while (SqlDR.Read()) { comboBox2.Items.Add(SqlDR.GetString(0)); } }
Error 1 Operator '+' cannot be applied to operands of type 'string' and 'method group'