Compactar informacion mensual

Hola todo expertos!!
Espero alguien em pueda ayudar, utilizo una base de access 97 y visual basic 6, tengo 20 tablas en la base de datos.
Lo que necesito saber que procedimiento utilizar para no tener problemas con la base de datos como que se queden bloqueadas o se llenen ya que alrededor de 8 tablas son de detalle y se manejan varios datos.
Tengo ya dentro del programa opcion para repar y compactar la base de datos en caso de que se dañe, Ahora me gustaria saber que instrucciones o procedimiento utilizar para crear tablas dentro del mismo sistema por ejemplo Para separar la informacion mensualmente, esta forma se me ocurrio para tener organizado todos los meses de las ventas que se realizen y asi no saturar una misma tabla, ahora bien este procesimiento es optimo o hay otras formas con mayor rendimiento y como le hago para solucionarlo.
Cualquier comentario es bien recibido.. Gracias

1 respuesta

Respuesta
1
Una opcion es hacer copias de la tabla dentro de la misma base de datos o a otra (copia de seguridad). Este codigo no hace exactamente eso pero te puede ayudar:
Public Function fbRefrescarTabla(ByVal CSERV As ADODB.Connection, _
ByRef BDLOCAL As ADODB. Connection, ByVal sNameTable As String, _
Optional ByVal sWHERE As String, Optional ByRef sError As String) As Boolean
' Copia los datos de una tabla remota a local, creando la tabla a partir de
' la estructura remota...
Dim CAT As ADOX.Catalog, TBL As ADOX.Table, PK As ADOX.Key, COL As ADOX.Column
Dim RAUX As ADODB.Recordset
Dim sName As String, lType As Long, lSize As Long, bIsNull As Boolean
Dim sFIELDS As String, sVALUES As String
On Error GoTo TratarError
BDLOCAL.BeginTrans
Set CAT = New ADOX.Catalog
Set CAT.ActiveConnection = BDLOCAL
' Borramos la tabla si existe
If fbExisteTabla(BDLOCAL, sNameTable) Then
CAT.Tables.Delete sNameTable
CAT.Tables.Refresh
End If
' Creamos la tabla...
Set RAUX = CSERV.OpenSchema(adSchemaColumns, Array(Empty, Empty, sNameTable))
If (RAUX.BOF And RAUX.EOF) Then
sError = "No existe la tabla en el servidor remoto."
Else
Set TBL = New ADOX.Table
TBL.name = sNameTable
' Añadimos los campos...
RAUX.MoveFirst
Do While Not RAUX.EOF
sName = RAUX("COLUMN_NAME")
lType = RAUX.Fields("DATA_TYPE")
bIsNull = RAUX("IS_NULLABLE")
If Not IsNull(RAUX.Fields("CHARACTER_MAXIMUM_LENGTH")) Then
lSize = RAUX.Fields("CHARACTER_MAXIMUM_LENGTH")
Else
lSize = 0
End If
TBL.Columns.Append sName, lType, lSize
If bIsNull Then TBL.Columns(sName).Attributes = adColNullable
RAUX.MoveNext
Loop
RAUX.Close
' Añadimos la clave primaria...
Set RAUX = CSERV.OpenSchema(adSchemaIndexes, Array(Empty, Empty, Empty, Empty, sNameTable))
If Not (RAUX.BOF And RAUX.EOF) Then
RAUX.MoveFirst
Set PK = New ADOX.Key
PK.name = RAUX("INDEX_NAME")
PK.Type = adKeyPrimary
Do While Not RAUX.EOF
If RAUX("PRIMARY_KEY") Then
sName = RAUX("COLUMN_NAME")
lType = TBL.Columns(sName).Type
lSize = TBL.Columns(sName).DefinedSize
PK.Columns.Append sName, lType, lSize
End If
RAUX.MoveNext
Loop
TBL.Keys.Append PK
End If
' Añadimos la tabla a la BD...
CAT.Tables.Append TBL
CAT.Tables.Refresh
End If
RAUX.Close
If (sError = Empty) Then
Set RAUX = CSERV.Execute("SELECT * FROM [" & sNameTable & "]" & _
IIf(sWHERE <> Empty, " WHERE " & sWHERE, Empty))
If Not (RAUX.BOF And RAUX.EOF) Then
RAUX.MoveFirst
For Each COL In TBL.Columns
sFIELDS = sFIELDS & IIf(Len(sFIELDS) = 0, Empty, ", ") & COL.name
Next
sFIELDS = "(" & sFIELDS & ")"
Do While Not RAUX.EOF
sVALUES = Empty
For Each COL In TBL.Columns
sVALUES = sVALUES & IIf(Len(sVALUES) = 0, Empty, ", ")
If IsNull(RAUX.Fields(COL.name).Value) Then
sVALUES = sVALUES & "NULL"
Else
Select Case COL.Type
Case adBigInt, adDecimal, adDouble, adInteger, adNumeric, adCurrency, adSingle, adSmallInt, adTinyInt, adBinary, adUnsignedBigInt, adUnsignedInt, adUnsignedSmallInt, adUnsignedTi

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas