C# windows application
hi friends ....i want get all the databases list in windows application .. is it possible ? i think it is possible but how to start to write coding for this ..
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
srikanthreddyPosted Dec 29, 2011, 4:39 AM
srikanthreddyPosted Dec 29, 2011, 4:39 AM
srikanthreddyPosted Dec 29, 2011, 4:38 AM
Vikrant JadhavPosted Dec 22, 2011, 2:57 AM
Use the following code u get desire result display in Datagridview
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace DisplayDBNames
{
public partial class frmForm : Form
{
SqlConnection conn = new SqlConnection("Server=PC-520\\SQLEXPRESS;Database=SampleDB;Integrated Security=True");
private void btnShowDB_Click(object sender, EventArgs e)
{
conn.Open();
DataTable dbList = conn.GetSchema("Databases");//get all database list
conn.Close();
dataGridView1.DataSource =dbList;
}
}
}
Thanks & Regards
Vikrant Jadhav
If this post is helpful to you Then Please mark as a "Correct Answer".
Pravin GhadgePosted Dec 22, 2011, 2:49 AM
Pravin GhadgePosted Dec 22, 2011, 2:26 AM
Con.open();
Dataset ds=new DataSet();
adp.Fill(ds);
In ds, u will get list of all databases.
Where u want to fill this list.