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]
Loading
Jignesh TrivediPosted Sep 6, 2013, 12:29 AM
I think, you want to create connection string dynamically right?
If yes than you can put setting like database name, server name etc into the config file.
one more thing connection made on database not on table.
hope this will help you.
Abhineet SrivastavaPosted Sep 5, 2013, 10:35 PM