Get All Databases in SQL Server in Ado.net VB.NET
If User wants to installed databases in the SQL Server Instance. user can get all databases using SQLConnection GetSchema Object.
> Add gridView to aspx page
<asp:GridView Font-Names="'Times New Roman',roman"
Caption="<h3 STYLE='BACKGROUND:TEAL;COLOR:WHITE'>Using SqlConnection Get All Databases in ASP.NET</H3>"
ID="GridView1" runat="server" Height="179px" Width="652px">
<HeaderStyle BackColor="Teal" ForeColor="WhiteSmoke" />
</asp:GridView>
Caption="<h3 STYLE='BACKGROUND:TEAL;COLOR:WHITE'>Using SqlConnection Get All Databases in ASP.NET</H3>"
ID="GridView1" runat="server" Height="179px" Width="652px">
<HeaderStyle BackColor="Teal" ForeColor="WhiteSmoke" />
</asp:GridView>
> Query Database objects(Here assumes master database default)
Dim conn As SqlConnection = New SqlConnection("Data Source=localhost\sqlexpress2012;trusted_connection=yes;")
conn.Open()
Dim schemaTable As DataTable = conn.GetSchema("DATABASES")
GridView1.DataSource = schemaTable
GridView1.DataBind()
conn.Open()
Dim schemaTable As DataTable = conn.GetSchema("DATABASES")
GridView1.DataSource = schemaTable
GridView1.DataBind()
> OUTPUT
database_name | dbid | create_date |
---|---|---|
master | 1 | 4/8/2003 9:13:36 AM |
tempdb | 2 | 2/27/2013 2:19:13 PM |
model | 3 | 4/8/2003 9:13:36 AM |
msdb | 4 | 2/10/2012 9:02:17 PM |
testee | 5 | 10/23/2012 8:16:28 PM |
nopcommerce | 6 | 10/26/2012 8:36:56 AM |
AdventureWorks2012 | 7 | 10/26/2012 10:27:06 PM |
pubs | 8 | 10/27/2012 9:00:25 AM |
Northwind | 9 | 10/27/2012 9:02:20 AM |
Tags:Get All Databases in SQL Server in ASP.NET VB.NET,get all databases supported by SQL Server 2012, get All database names and DBID in asp.net Vb.NET , get Database Creation Date, get Database DBID, get database Name,get all databases in sql server using ado.net vb.net.
No comments:
Post a Comment