Page 1 of 1
Get Database size
Posted: Tue 04 Mar 2008 12:19
by b.szabo
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
Posted: Tue 04 Mar 2008 15:19
by Alexey.mdr
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
Posted: Thu 06 Mar 2008 02:44
by b.szabo
Thanks it worked perfect,
Barnabás
Posted: Thu 06 Mar 2008 06:31
by Alexey.mdr
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.