Get Database size

Get Database size

Postby b.szabo » Tue 04 Mar 2008 12:19

Hi,

I want to get the size, of the selected Database in bytes. Could you help me out with some vb code.

Thanks,
Barnabás
b.szabo
 
Posts: 14
Joined: Wed 04 Jul 2007 05:50

Postby Alexey.mdr » Tue 04 Mar 2008 15:19

Here's the code.
Hope you will easily get the idea.
Code: Select all
Imports CoreLab.Data
Imports CoreLab.MySql
Module Module1
    Sub Main()
        Dim mySelectQuery As String
        mySelectQuery = "show table status"

        Dim myConnection As New MySqlConnection("user id=root;password=root;host=localhost;database=test;")
        Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)

        Dim totalSpace As Int32
        totalSpace = 0

        myConnection.Open()
        Dim myReader As MySqlDataReader
        myReader = myCommand.ExecuteReader()

        While (myReader.Read())
            Console.WriteLine(myReader.GetInt32(6) & "," & myReader.GetInt32(6))
            totalSpace += myReader.GetInt32(6) + myReader.GetInt32(6)
        End While

        myReader.Close()
        myConnection.Close()
        Console.WriteLine(totalSpace)
        Console.Read()

    End Sub
End Module

Alexey.mdr
 
Posts: 729
Joined: Thu 13 Dec 2007 10:24

Postby b.szabo » Thu 06 Mar 2008 02:44

Thanks it worked perfect,

Barnabás
b.szabo
 
Posts: 14
Joined: Wed 04 Jul 2007 05:50

Postby Alexey.mdr » Thu 06 Mar 2008 06:31

You are welcome!
Hope it was quite clear that I had added data size column and index size column.
So you get the total database size.
Feel free to contact us if you have any further questions about MyDirect .NET.
Alexey.mdr
 
Posts: 729
Joined: Thu 13 Dec 2007 10:24


Return to dotConnect for MySQL