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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pravin GhadgeRank #1,340 · 1.3K reputationPosted Dec 21, 2011, 9:26 PM EST
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.
Pravin GhadgeRank #1,340 · 1.3K reputationPosted Dec 21, 2011, 9:49 PM EST
Vikrant Jadhav64 reputationPosted Dec 21, 2011, 9:57 PM EST
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".
srikanthreddy27 reputationPosted Dec 28, 2011, 11:38 PM EST
srikanthreddy27 reputationPosted Dec 28, 2011, 11:39 PM EST
srikanthreddy27 reputationPosted Dec 28, 2011, 11:39 PM EST