- Le Sub Main du module general pour la connexion initiale
- Sub Main()
- 'Je verifie si c'est le premier lancement
- 'le fichier video.ini contient l'info du type de base
- 'ici 1-->Access 2-->Sql
- Open "c:\program files\videotheque\video.ini" For Input As #1
- Line Input #1, typebase
- typedebase = Mid(typebase, 17, 18)
- Line Input #1, NomdeBase
- NomdeBase = Mid(NomdeBase, 13, 18)
- 'Line Input #1, Majorite
- 'Majorite = Mid(Majorite, 13, 18)
- Close
- If NomdeBase = "" Then NomdeBase = "films.mdb"
-
- If CnImport.State = adStateOpen Then CnImport.Close: Set CnImport = Nothing
- CnImport.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
- "Data Source=c:\Program Files\Videotheque\" & NomdeBase
-
- Select Case typedebase
- Case 1
- frmconnexion.typeconnexion = "Access"
- If Cn.State = adStateOpen Then Cn.Close: Set Cn = Nothing
- Cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
- "Data Source=c:\Program Files\Videotheque\" & NomdeBase
- Case 2
- frmconnexion.typeconnexion = "Sql"
- If Cn.State = adStateOpen Then Cn.Close: Set Cn = Nothing
- With Cn
- .Provider = "SQLOLEDB"
- .ConnectionString = "datasource=DSN=FILMS;" & _
- "server=; user id=sa;" & _
- "initial catalog=FILMS"
- .Open
- End With
- With cmd
- .ActiveConnection = Cn
- .CommandType = adCmdText
- End With
- Case Else
- frmconnexion.typeconnexion = "Access"
- Open "c:\program files\videotheque\video.ini" For Output As #1
- Print #1, "typeconnexion = 1"
- Print #1, "Nomdebase=" & NomdeBase
- Close
- End Select
-
- et le code dans la fenetre "connexion"
-
- frmconnexion.typeconnexion = "Access"
- If Cn.State = adStateOpen Then Cn.Close: Set Cn = Nothing
- Cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
- "Data Source=c:\Program Files\Videotheque\" & File1.FileName
- NomdeBase = File1.FileName
- frmgestion.Caption = " Accès Principal " & " Type de Base de Données : " & frmconnexion.typeconnexion & " --- Nom de la Base : " & NomdeBase
-
- ' y a du code entre bien sur mais il ne concerne plus la connexion donc je ne le mets pas
-
- Open "c:\program files\videotheque\video.ini" For Input As #1
- Line Input #1, typedebase
- typedebase = Mid(typedebase, 17, 18)
- Line Input #1, NomdeBase
- NomdeBase = Mid(NomdeBase, 13, 18)
- Close
- Select Case typedebase
- Case 1
- typeconnexion = "Access"
- 'NomdeBase = "Films.mdb"
- Case 2
- typeconnexion = "Sql"
- End Select
-
-
-
Le Sub Main du module general pour la connexion initiale
Sub Main()
'Je verifie si c'est le premier lancement
'le fichier video.ini contient l'info du type de base
'ici 1-->Access 2-->Sql
Open "c:\program files\videotheque\video.ini" For Input As #1
Line Input #1, typebase
typedebase = Mid(typebase, 17, 18)
Line Input #1, NomdeBase
NomdeBase = Mid(NomdeBase, 13, 18)
'Line Input #1, Majorite
'Majorite = Mid(Majorite, 13, 18)
Close
If NomdeBase = "" Then NomdeBase = "films.mdb"
If CnImport.State = adStateOpen Then CnImport.Close: Set CnImport = Nothing
CnImport.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\Program Files\Videotheque\" & NomdeBase
Select Case typedebase
Case 1
frmconnexion.typeconnexion = "Access"
If Cn.State = adStateOpen Then Cn.Close: Set Cn = Nothing
Cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\Program Files\Videotheque\" & NomdeBase
Case 2
frmconnexion.typeconnexion = "Sql"
If Cn.State = adStateOpen Then Cn.Close: Set Cn = Nothing
With Cn
.Provider = "SQLOLEDB"
.ConnectionString = "datasource=DSN=FILMS;" & _
"server=; user id=sa;" & _
"initial catalog=FILMS"
.Open
End With
With cmd
.ActiveConnection = Cn
.CommandType = adCmdText
End With
Case Else
frmconnexion.typeconnexion = "Access"
Open "c:\program files\videotheque\video.ini" For Output As #1
Print #1, "typeconnexion = 1"
Print #1, "Nomdebase=" & NomdeBase
Close
End Select
et le code dans la fenetre "connexion"
frmconnexion.typeconnexion = "Access"
If Cn.State = adStateOpen Then Cn.Close: Set Cn = Nothing
Cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\Program Files\Videotheque\" & File1.FileName
NomdeBase = File1.FileName
frmgestion.Caption = " Accès Principal " & " Type de Base de Données : " & frmconnexion.typeconnexion & " --- Nom de la Base : " & NomdeBase
' y a du code entre bien sur mais il ne concerne plus la connexion donc je ne le mets pas
Open "c:\program files\videotheque\video.ini" For Input As #1
Line Input #1, typedebase
typedebase = Mid(typedebase, 17, 18)
Line Input #1, NomdeBase
NomdeBase = Mid(NomdeBase, 13, 18)
Close
Select Case typedebase
Case 1
typeconnexion = "Access"
'NomdeBase = "Films.mdb"
Case 2
typeconnexion = "Sql"
End Select