VBMGNEW1.frm

 VERSION 5.00
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form Form1
   BackColor       =   &H00C0FFFF&
   Caption         =   "MYSQL MERGE (WEBSITE :http:\\appnu.x10.mx)"
   ClientHeight    =   3090
   ClientLeft      =   165
   ClientTop       =   855
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   10710
   ScaleWidth      =   15240
   StartUpPosition =   3  'Windows Default
   WindowState     =   2  'Maximized
   Begin VB.CommandButton Command2
      BackColor       =   &H00C0FFC0&
      Caption         =   "CLICK HERE SECOND"
      BeginProperty Font
         Name            =   "MS Sans Serif"
         Size            =   13.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   855
      Left            =   7320
      Style           =   1  'Graphical
      TabIndex        =   15
      Top             =   6480
      Width           =   3735
   End
   Begin VB.Frame Frame3
      BackColor       =   &H00FFFFFF&
      Caption         =   "OUTPUT TABLE NAME"
      BeginProperty Font
         Name            =   "MS Sans Serif"
         Size            =   13.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1095
      Left            =   120
      TabIndex        =   13
      Top             =   4080
      Width           =   11895
      Begin VB.TextBox Text6
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   615
         Left            =   4320
         TabIndex        =   4
         Top             =   240
         Width           =   6255
      End
      Begin VB.Label Label8
         BackColor       =   &H00FFFFFF&
         Caption         =   "ENTER OUTPUT FILE NAME "
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   120
         TabIndex        =   14
         Top             =   600
         Width           =   4455
      End
   End
   Begin VB.Frame Frame2
      BackColor       =   &H00FFC0FF&
      Caption         =   "ODBC DETAILS"
      BeginProperty Font
         Name            =   "MS Sans Serif"
         Size            =   13.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1215
      Left            =   120
      TabIndex        =   10
      Top             =   2760
      Width           =   12015
      Begin VB.TextBox Text3
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   5160
         TabIndex        =   3
         Top             =   480
         Width           =   6255
      End
      Begin VB.Label Label4
         BackColor       =   &H00FFFFFF&
         Caption         =   "PLEASE FIRST CREATE A ODBC FOR MY-SQL"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   5160
         TabIndex        =   12
         Top             =   240
         Width           =   6375
      End
      Begin VB.Label Label3
         BackColor       =   &H00FFFFFF&
         Caption         =   "           ENTER ODBC NAME                                  (EG:VBSQL)"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   615
         Left            =   120
         TabIndex        =   11
         Top             =   360
         Width           =   4575
      End
   End
   Begin VB.Frame Frame1
      BackColor       =   &H00FFFFC0&
      Caption         =   "MYSQL DETAILS"
      BeginProperty Font
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2775
      Left            =   120
      TabIndex        =   6
      Top             =   0
      Width           =   12015
      Begin VB.TextBox Text7
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   735
         Left            =   5280
         TabIndex        =   2
         Top             =   1920
         Width           =   6255
      End
      Begin VB.TextBox Text1
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   735
         Left            =   5280
         TabIndex        =   0
         Top             =   240
         Width           =   6375
      End
      Begin VB.TextBox Text2
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   735
         Left            =   5280
         TabIndex        =   1
         Top             =   1080
         Width           =   6255
      End
      Begin VB.Label Label9
         BackColor       =   &H00FFFFFF&
         Caption         =   "ENTER DATABASE FOR MY-SQL                              ( EG:STAFF)"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   615
         Left            =   240
         TabIndex        =   9
         Top             =   1920
         Width           =   4815
      End
      Begin VB.Label Label2
         BackColor       =   &H00FFFFFF&
         Caption         =   "ENTER PASSWORD FOR MY-SQL USER                    (EG:GDC)"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   615
         Left            =   120
         TabIndex        =   8
         Top             =   1200
         Width           =   5055
      End
      Begin VB.Label Label1
         BackColor       =   &H00FFFFFF&
         Caption         =   "ENTER USER NAME OF MY-SQL                            ( EG:ROOT)"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   615
         Left            =   120
         TabIndex        =   7
         Top             =   360
         Width           =   4935
      End
   End
   Begin VB.CommandButton Command1
      BackColor       =   &H00FFFFFF&
      Caption         =   "CLICK HERE FIRST"
      BeginProperty Font
         Name            =   "MS Sans Serif"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   975
      Left            =   7320
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   5400
      Width           =   3735
   End
   Begin MSDataGridLib.DataGrid DataGrid1
      Height          =   4455
      Left            =   120
      TabIndex        =   16
      Top             =   5280
      Width           =   6495
      _ExtentX        =   11456
      _ExtentY        =   7858
      _Version        =   393216
      AllowUpdate     =   -1  'True
      HeadLines       =   1
      RowHeight       =   19
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "PRESS CTRL+T TO DELETE UNWANTED FILE NAMES"
      ColumnCount     =   2
      BeginProperty Column00
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0
         BeginProperty Column00
         EndProperty
         BeginProperty Column01
         EndProperty
      EndProperty
   End
   Begin VB.Menu EXIT
      Caption         =   "EXIT"
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim cmd As String
Dim cmd1 As String
Dim sql As String
Dim sql1 As String
Dim cn As Connection
Public cn1 As Connection
Dim cn2 As Connection
Dim cn3 As Connection
Dim cn7 As Connection
Dim rs7 As ADODB.Recordset
Dim rs As ADODB.Recordset
Dim rs1 As ADODB.Recordset
Dim rs2 As ADODB.Recordset
Dim rs3 As Recordset
Dim rs4 As ADODB.Recordset
Dim RS5 As ADODB.Recordset
Dim rs8 As Recordset
Dim rsf(14)
Dim a
Dim c1(100)
Dim c2(100)
Dim d1(100)
Dim d2(100)
Dim sok As Boolean
Dim z1 As Class1
Dim filen
Dim rcnt, fcnt
Private Sub Command1_Click()
On Error Resume Next
Command2.Enabled = False
If (Text1.Text <> "" And Text2.Text <> "" And Text3.Text <> "" And Text6.Text <> "" And Text7.Text <> "") Then
Call SELECTTABLE
Call gridshow
Command1.Enabled = False
Command2.Enabled = True
End If
End Sub

Private Sub Command2_Click()
On Error Resume Next
rs4.Close
Call CREATEDATA
filen = Trim(Text6.Text)
Dim i, j, k, aa, a, an, ac
Set cn = New Connection
Set rs = New ADODB.Recordset
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
Set rs4 = New ADODB.Recordset
Set RS5 = New ADODB.Recordset
cn.Open "Provider=MSDASQL.1;Persist Security Info=False;User ID=" & Trim(Text1.Text) & ";Data Source=" & Trim(Text3.Text) & ";Initial Catalog=" & Trim(Text7.Text) & ""
rs1.Open "select * from mg ", cn, , adLockPessimistic
cn.CursorLocation = adUseClient
    Do While Not rs1.EOF()
        aa = rs1("fname")
        AE = Trim(aa)
        aren = Trim(aa) + "m" + Trim(ddate)
        aold = Trim(AE)
        aa1 = "insert into " & Trim(filen) & "  select * from " & AE & ""
        aa2 = "insert into mgf (fname,rcnt)  select '" & AE & "' as 'fname',count(subject) as 'rcnt' from " & AE & "  group by 1 "
        aa3 = "CREATE TABLE if not exists " & aren & " LIKE " & aold & ""
        aa31 = "insert into " & aren & " select * from " & aold & ""
        aa4 = " drop table " & aold & ""
        aa5 = "select count(*) from  " & Trim(filen) & ""
        cn.Execute aa1
        cn.Execute aa2
        cn.Execute aa3
        cn.Execute aa31
        cn.Execute aa4
        cn.Execute aa5
        rs1.MoveNext
    Loop
MsgBox ("MERGING OVER")
Unload Me

End Sub
Private Sub DataGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyT Then
xx = rs4("fname")
  MsgBox ("" & xx & "        IS Record Deleted")
   rs4.Delete adAffectCurrent
End If
End Sub
Private Sub EXIT_Click()
Unload Me
End Sub

Private Sub Form_Load()
Set z1 = New Class1
Set cn1 = New Connection
Set rs = New ADODB.Recordset
Set rs3 = New ADODB.Recordset
Set rs4 = New ADODB.Recordset
cn1.CursorLocation = adUseClient
End Sub
Sub SELECTTABLE()
On Error GoTo err
str1 = "create table if not exists mg (fname varchar(15),up varchar(1))"
str2 = "truncate mg"
cn1.Open "Provider=MSDASQL.1;Persist Security Info=False;User ID=" & Trim(Text1.Text) & ";Data Source=" & Trim(Text3.Text) & ";Initial Catalog=" & Trim(Text7.Text) & ""
cn1.Execute str1
cn1.Execute str2
strp = "show tables"
  Set rs3 = cn1.Execute(strp)
If Not (rs3.EOF Or rs3.BOF) Then
    Do While Not rs3.EOF
     aa = rs3(0)
     Str3 = "insert into  mg (fname)values('" & aa & "')"
     cn1.Execute Str3
     rs3.MoveNext
  Loop
End If
rs3.Close
Exit Sub
err:
   MsgBox err.Description
End Sub
Sub gridshow()
Set rs4 = New ADODB.Recordset
rs4.Open "select * from mg", cn1, adOpenStatic, adLockOptimistic
Set DataGrid1.DataSource = rs4
MsgBox ("please press ctrl+t to delete the unwanted files in grid and keep the common file structure to merge")
End Sub
Function CREATEDATA()
filen = Trim(Text6.Text)
aflag = 0
Set cn1 = New Connection
Set rs = New ADODB.Recordset
Set rs3 = New ADODB.Recordset
Set rs4 = New ADODB.Recordset
cn1.Open "Provider=MSDASQL.1;Persist Security Info=False;User ID=" & Trim(Text1.Text) & ";Data Source=" & Trim(Text3.Text) & ";Initial Catalog=" & Trim(Text7.Text) & ""
rs3.Open "select * from mg ", cn1, , adLockPessimistic
aa = rs3("fname")
rs.Open "create table IF NOT EXISTS " + filen + " as (select * from " + aa + ")", cn1, , adLockOptimistic
strt = "truncate " + filen + ""
cn1.Execute strt
rs4.Open "create table IF NOT EXISTS mgf (fname varchar(15),cnt integer)", cn1, , adLockPessimistic
strt = "truncate mgf "
cn1.Execute strt
rs3.Close
rs.Close
rs4.Close
End Function

Project Homepage: