how many tables exist in a database - VB.NET

A table is responsible for storing data in the database. A table is a set of data elements that is organized using a model of vertical columns and horizontal rows.A database is made up of many linked tables of rows and columns, each containing specific data.

In many situations you should find the no. of tables exist in your database. Everything about your SQL Server database is stored in its system tables.

Returns a row for each table object, currently only with sys.objects.type = U. System tables should not be altered directly by any user

Imports System.Data
Imports System.Data.SqlClient
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim connetionString As String
        Dim connection As SqlConnection
        Dim command As SqlCommand
        Dim adapter As New SqlDataAdapter
        Dim ds As New DataSet
        Dim tables As DataTable
        Dim i As Integer
        Dim sql As String

        connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"
        sql = "Select DISTINCT(name) FROM sys.Tables"
        connection = New SqlConnection(connetionString)

            command = New SqlCommand(sql, connection)
            adapter.SelectCommand = command

            For i = 0 To ds.Tables(0).Rows.Count - 1

        Catch ex As Exception
            MsgBox("Can not open connection ! ")
        End Try
    End Sub
End Class (C) 2021    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.
SiteMap  | Terms  | About