SQL Server Performance

Dynamic for Visual Basic6

Discussion in 'SQL Server 2005 T-SQL Performance Tuning' started by ohne, Oct 14, 2006.

  1. ohne New Member

    Hi to everyone.

    How can i create a dynamic connection to sql server from visual basic 6? I have this code:

    cPersonalFile = gDrive & gDir & "NwPerson.mdb"
    cEmpleadosFile = gDrive & gDir & "DataOper.mdb"
    cTemporalFile = "C:SistemasPersonalNwPerson.mdb"
    On Error GoTo OpenDataError

    'Base de datos para crear archivos temporales...
    Set MainTmpMDB = DBEngine.Workspaces(0).OpenDatabase(cTemporalFile, False, False)
    Set dbTmp = OpenDatabase(App.Path & " mpnote.mdb", False, False) 'EMMG 10-jun-02
    Set MainMDB = DBEngine.Workspaces(0).OpenDatabase(cPersonalFile, False, False)
    Set PersonalST = MainMDB.OpenRecordset("Personal", dbOpenTable)
    Set AmonestacionesST = MainMDB.OpenRecordset("Amonestaciones", dbOpenTable)
    Set AusentismosST = MainMDB.OpenRecordset("Ausentismos", dbOpenTable)
    Set ClasesST = MainMDB.OpenRecordset("Clases", dbOpenTable)
    Set AreasST = MainMDB.OpenRecordset("Areas", dbOpenTable)
    Set PuestosST = MainMDB.OpenRecordset("Puestos", dbOpenTable)
    Set ActividadesST = MainMDB.OpenRecordset("Actividades", dbOpenTable)
    Set TurnosST = MainMDB.OpenRecordset("Turnos", dbOpenTable)
    Set TiposDeAusentismoST = MainMDB.OpenRecordset("TiposDeAusentismos", dbOpenTable)
    Set EscolaridadesST = MainMDB.OpenRecordset("Escolaridades", dbOpenTable)
    Set TiposDeEdoCivilST = MainMDB.OpenRecordset("TiposDeEdoCivil", dbOpenTable)
    Set ColoniasST = MainMDB.OpenRecordset("Colonias", dbOpenTable)
    Set MovimientosST = MainMDB.OpenRecordset("Movimientos", dbOpenTable)
    Set TiempoExtraST = MainMDB.OpenRecordset("TiempoExtra", dbOpenTable)
    PersonalST.Index = "PrimaryKey": AmonestacionesST.Index = "PrimaryKey"
    AusentismosST.Index = "PrimaryKey": ClasesST.Index = "PrimaryKey"
    AreasST.Index = "PrimaryKey": PuestosST.Index = "PrimaryKey"
    ActividadesST.Index = "PrimaryKey": TurnosST.Index = "PrimaryKey"
    TiposDeAusentismoST.Index = "PrimaryKey": EscolaridadesST.Index = "PrimaryKey"
    TiposDeEdoCivilST.Index = "PrimaryKey": ColoniasST.Index = "PrimaryKey"
    MovimientosST.Index = "PrimaryKey": TiempoExtraST.Index = "PrimaryKey"

    How can i do it with sql server instead of access? is it possible?

    Love... how is it?
  2. Adriaan New Member

    Use ADO objects to access SQL Server.

    If you have Access, you might also choose DAO objects, which are MUCH simpler to use.

Share This Page