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.
Loading
Abhay ShankerPosted Aug 21, 2014, 2:14 AM
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();
}
}
Ravi KumarPosted Aug 21, 2014, 2:02 AM
you give the connection string in app.config
the fallowing code you write in *.cs
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["UniqueName"]);
Ranjit PowarPosted Aug 21, 2014, 1:26 AM
http://www.c-sharpcorner.com/Blogs/15749/take-sql-sever-database-backup-from-winform.aspx