Hi,
I was trying to get SQL database names once after logging in. how do i achieve it in windows form C#?
i have windows form with 3 fields
1) IP address
2) user name
3) Password
once after filling the above form it should redirect to another form where in it should display all the authenticated database name for that entered user.
Display SQL database for authenticated users
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Ranjit PowarRank #553 · 4.4K reputationPosted Aug 20, 2014, 9:26 PM EDT
http://www.c-sharpcorner.com/Blogs/15749/take-sql-sever-database-backup-from-winform.aspx
Ravi KumarRank #2,085 · 690 reputationPosted Aug 20, 2014, 10:02 PM EDT
you give the connection string in app.config
the fallowing code you write in *.cs
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["UniqueName"]);
Abhay ShankerRank #375 · 6.7K reputationPosted Aug 20, 2014, 10:14 PM EDT
protected void Connect(object sender, EventArgs e)
{
String connString = string.Format("Data Source={0};User ID={1};Password={2}", txtInstance.Text, txtUserName.Text, txtPassword.Text);
using (SqlConnection con = new SqlConnection(connString))
{
con.Open();
DataTable dtDatabases = con.GetSchema("Databases");
con.Close();
ddlDatabases.DataSource = dtDatabases;
ddlDatabases.DataTextField = "database_name";
ddlDatabases.DataValueField = "dbid";
ddlDatabases.DataBind();
}
}