string Connstring = "Data Source=" + txtservername.Text + "; Initial Catalog=" + txtLDatabase.Text + "; Persist Security Info=true; User ID=" + txtLUName.Text + "; Password=" + txtLPassword.Text + ";Connect Timeout=0"; //"Data Source=" + txtservername.Text + "; Initial Catalog=" + txtLDatabase.Text + "; Persist Security Info=true; User ID=" + txtLUName.Text + "; Password=" + txtLPassword.Text + ";Connect Timeout=0"; SqlConnection cn = new SqlConnection(Connstring); try { cn.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM sys.Databases WHERE state = 0", cn); SqlDataAdapter adp = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); cmd.CommandTimeout = 0; adp.Fill(ds); cmd.Dispose(); cmd = new SqlCommand("SELECT * FROM master..sysprocesses WHERE spid > 50", cn); DataSet ds1 = new DataSet(); SqlDataAdapter adp1 = new SqlDataAdapter(cmd); adp1.Fill(ds1); string str = cmd.ExecuteScalar().ToString(); if (ds.Tables[0].Rows.Count != 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) ddlPublisherServer.Items.Add(ds.Tables[0].Rows[i][0]); //dataGridView1.DataSource = ds.Tables[0]; dataGridView1.DataSource = ds.Tables[0]; } } catch (Exception ex) { MessageBox.Show("Invalid User Name or Password" + ex.Message); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)