Esportazione dati con MyOLEDB3

venerdì 01 ottobre 2004 - 09.58

w_t Profilo | Junior Member

[B]Problema:[/B] Devo fare il BACKUP dei dati contenuti nelle tabelle del Database, il tutto ripetuto per 4 PC dove risiede un Database mySQL ciascuno.


[U]Il dettaglio:[/U] importante è che non devo fare il BACKUP totale, ma solamente il 95% dei dati contenuti nella tabella che poi io impostero la limitazione tramite la Query SQL con un WHERE !!!!


[U]Il fine:[/U] creare in un quinto Database le tabelle presenti negli altri 4, per le tabelle con i nomi identici sommo i record nella tabella di destinazione, per le tabelle con nomi diversi le aggiungo al Database e inserisco i dati, in modo da avere un grande e unico Database che non e' altro che la somma dei 4 Database.


[U]Dimensioni:[/U] 1 Database mySQL contiene 250 tabelle le quali contengono mediamente 500 record ciascuna suddivisi in 10 colonne, peso medio di 1 Database 10Mb.


[U]Detto questo:[/U] io ho provato facendolo tramite dei cicli WHILE nidificati come da esempio.........

[code] Private Sub Estract_Insert()

oConnDB1.Open()
Dim schemaTable As DataTable = oConnDB1.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing)
Dim myArray(1000) As String
Dim i As Integer
For i = 0 To schemaTable.Rows.Count - 1
myArray(i) = schemaTable.Rows(i).Item(2).ToString
Next
oConnDB1.Close()

Dim TableName As String
Dim count As Integer
For count = 0 To myArray.Length Step 1
TableName = myArray(count)
'controlla che sia una tabella 'Utente'
If TableName.Substring(0, 5) = "logs_" Then
'crea la nuova tabella se non esiste già
Try
Dim oCommDB5 As New OleDbCommand("CREATE TABLE IF NOT EXISTS " & TableName & " ( " & _
"ID int(11)," & _
"Ora_Start_In datetime," & _
"Ora_End_In datetime," & _
"Ora_Start_Out datetime," & _
"Ora_End_Out datetime," & _
"CLI varchar(50)," & _
"Chiamato varchar(50)," & _
"Esito varchar(50)," & _
"Operator varchar(50))", oConnDB5)
oCommDB5.Connection.Open()
oCommDB5.ExecuteNonQuery()
oCommDB5.Connection.Close()
Catch
MessageBox.Show("Si è verificato un errore dirante la creazione della nuova tabella - " & TableName & "", "Errore!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
Exit Sub
End Try
'estrae i dati dalla tabella remota
Try
oConnDB1.Open()
Dim oComm As New OleDbCommand("SELECT * FROM " & TableName & " ORDER BY ID DESC", oConnDB1)
Dim oRead As OleDbDataReader = oComm.ExecuteReader
While oRead.Read
'inserisce i dati nella tabella locale
Try
Dim oComm1 As New OleDbCommand("INSERT INTO " & TableName & "(" & _
"ID," & _
"aaa," & _
"bbb," & _
"ccc," & _
"ddd," & _
"eee," &
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5