Click here to Skip to main content
13,146,315 members (45,255 online)
Rate this:
Please Sign up or sign in to vote.
See more:
How repair mysql Table thourgh 10 using code
Posted 23-Feb-13 0:30am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

That's impossible to answer. Since we know nothing about how it's "damaged" how could we possibly tell you how it should be "fixed"?
AnnuBhai 15-Mar-13 7:38am
2: Dim sTableName() As String
3: Dim iTableRange As Integer
4: Dim iCount As Integer
5: Dim vTableRepair
6: Dim sTableRepair As String
7: Dim sfile As String
8: Dim BscFiles As New BasicFunction.Files
9: Dim mb As MySqlBackup
10: mb = New MySqlBackup(strc_Connstr_Mysql.SmartHawk)
11: sSQL = "Show tables"
12: ReDim sTableName(mb.DatabaseInfo.AllTableNames.Length)
13: Dim txttrm_createlog As TextStream
14: Dim fsoProcessLog As New FileSystemObject
Dim dtEnd As Date
81: Dim i As Integer

15: Array.Copy(mb.DatabaseInfo.AllTableNames, sTableName, mb.DatabaseInfo.AllTableNames.Length) 'copy array mb.DatabaseInfo.AllTableNames to sTableName

16: iCount = mb.DatabaseInfo.AllTableNames.Length
17: Dim LVItem As ListViewItem = New ListViewItem 'Creating object of the listview control

18: For iTableRange = 1 To mb.DatabaseInfo.AllTableNames.Length - 1 'loop for all tables of the database

19: prgBarGo.Value = prgBarGo.Value + Fix(100 / mb.DatabaseInfo.AllTableNames.Length)

20: LVItem = LvCheckNRpr.Items.Add("Checking Table " & sTableName(iTableRange).ToString) 'Adding new line in listview control

21: LvCheckNRpr.Refresh()

22: sSQL = "Check Table " & sTableName(iTableRange) & " medium"

23: sTableRepair = TableRepair(sSQL) 'firing query and returns result of that query

24: vTableRepair = Split(sTableRepair, ",") 'Spliting result of that query

25: If vTableRepair(2) <> "warning" Then

26: If Trim(vTableRepair(3)) = "Table is already up to date" Or Trim(vTableRepair(3)) = "OK" Then

27: LVItem.SubItems.Add("Table " & sTableName(iTableRange) & " Found Up To Date") 'Adding sub item in listview cntrol
28: LVItem.SubItems.Add("No Action Required") 'Adding sub item in listview cntrol
29: LVItem.SubItems.Add("Healthy") 'Adding sub item in listview cntrol

30: ElseIf vTableRepair(2) = "error" And vTableRepair(3) = "Corrupt" Then
31: LVItem.SubItems.Add(vTableRepair(3))

32: sfile = Application.StartupPath & "\" & Fix(Math.Round(1000) * 1000) & ".bat"

33: If BscFiles.mFileExist(sfile) = False Then
34: Create_Bat(sfile, sTableName(iTableRange)) 'Creating new batch file in applcation folder
35: Else
36: System.IO.File.Delete(sfile) 'If batch already in application folder then file will be delete and again create batch file in application folder
37: Create_Bat(sfile, sTableName(iTableRange)) 'Creating new batch file in applcation folder
38: End If

39: If BscFiles.mFileExist(sfile) = True Then
40: Shell(sfile) 'running created batch file
41: LVItem.SubItems.Add("Repair Required ") 'Adding sub item in listview cntrol
42: LVItem.SubItems.Add("Send For Repair") 'Adding sub item in listview cntrol

43: End If

44: sSQL = "Repair Table " & sTableName(iTableRange) & " use_frm"
45: g_FireSQL(sSQL) 'Firing query

46: sSQL = "Check Table " & sTableName(iTableRange) & " medium"

47: sTableRepair = TableRepair(sSQL) 'Again we have to check table repaired or not

48: vTableRepair = Split(sTableRepair, ",")

49: If Trim(vTableRepair(3)) = "Table is already up to date" Or Trim(vTableRepair(3)) = "OK" Then
50: LVItem.SubItems
AnnuBhai 15-Mar-13 7:38am
yes it is possible Dave Kreskowiak
AnnuBhai 15-Mar-13 7:41am
Here i have mysqlbacup dll using that dll i have all tables name
after that i created loop and for each tables if i got an error msg den i will create 1 batch file, in that batch file i wrote myisam check and recovery code and run that batch file and again check that table
Dave Kreskowiak 15-Mar-13 7:46am
I said your quesiton was impossible to answer because we didn't know anything about your database, which engine you were using, nor what you meant by "damaged".

I did NOT say repairing the database wasn't possible.

The quality of the answer you get is directly dictated by the quality of the question you ask, and you asked a poorly detaily question.
AnnuBhai 15-Mar-13 7:47am
here some other work also doing like adding value in listview control and handling progress bar controls
AnnuBhai 15-Mar-13 8:04am
k boss
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

what repair means ? clarify your needs..more briefly.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

first v have to check whether table is proper or not if proper den OK if not den have 2 repair it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170915.1 | Last Updated 14 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100