How to load Automatically a database
Hi,
That if you select and connectionstring that the database will automatically be loaded with a specific table - in this case: TripElement. Because I have it now hard coded, like this:
private string _connectionString = @"server=DEV12;database=prod_CycleTours_net2_backup_201107110300;uid=sa;pwd=misoft;";
I have a listbox with a list of connectionstrings and if you select an connectionstring from the listbox then automatically the database with the specific column will be loaded
I triied like this:
[code]
private void btn_SelectDatabase_Click(object sender, EventArgs e)
{
using (var _connectionString = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
using (var command = connection.CreateCommand())
{
command.CommandText = "SELECT ColumnName FROM [check]";
connection.Open();
using (var reader = command.ExecuteReader())
{
while (reader.Read())
txtConfigurationName.Text = reader["TripElement"].ToString();
}
}
}
[/code]