Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void Connection(object sender, EventArgs e)
- {
- string User = "";
- string Password = "";
- string Istanza = "";
- SqlConnection myConnection = null;
- try
- {
- User = LoginName1.Value;
- Password = Password1.Value;
- Istanza = DropDownIstance.SelectedItem.ToString();
- myConnection = new SqlConnection("user id="+User+";" +
- "password="+ Password + ";Data Source=" + Istanza + ";" +
- "Trusted_Connection=yes;" +
- "Database=main;" +
- "connection timeout=30");
- myConnection.Open();
- // Set up a command with the given query and associate
- // this with the current connection.
- using (SqlCommand cmd = new SqlCommand("SELECT name from sys.databases", myConnection))
- {
- using (IDataReader dr = cmd.ExecuteReader())
- {
- while (dr.Read())
- {
- DropDownListDB.Items.Add(dr[0].ToString());
- }
- }
- }
- }
- catch (Exception Err)
- {
- string ErrorMessage = Err.Message;
- }
- finally
- {
- myConnection.Close();
- }
- }
- protected void Connection(object sender, EventArgs e)
- {
- string User = "";
- string Password = "";
- string Istanza = "";
- SqlConnection myConnection = null;
- try
- {
- User = LoginName1.Value;
- Password = Password1.Value;
- Istanza = DropDownIstance.SelectedItem.ToString();
- myConnection = new SqlConnection("Server=" + Istanza + ";" +
- "Database=master;" +
- "User ID=" + LoginName1.Value.Trim() + ";" +
- "Password=" + Password1.Value.Trim() + ";" +
- "Trusted_Connection=False");
- myConnection.Open();
- // Set up a command with the given query and associate
- // this with the current connection.
- using (SqlCommand cmd = new SqlCommand("SELECT name from sys.databases", myConnection))
- {
- using (IDataReader dr = cmd.ExecuteReader())
- {
- while (dr.Read())
- {
- DropDownListDB.Items.Add(dr[0].ToString());
- }
- }
- }
- }
- catch (Exception Err)
- {
- string ErrorMessage = Err.Message;
- }
- finally
- {
- myConnection.Close();
- }
- }
Add Comment
Please, Sign In to add comment