Bonjour à tous,
Je viens de finir avec ma petite application avec vb6. Comme dernière étape je voudrai distribuer mon application pour une période limitéé et puis le programme va s'arréter en demandant à l'utilisateur d'entrer une clé pour activer le programme. J'ai trouvé ce code dans un forum que j'ai adapté et introduit dans mon application mais le code est associé avec DAO alors que moi je travaille avec ADO.J'aimerais bien que quelq'un m'aides pour qu'il soit compatible avec ADO.
Voici le code DAO:
End If
End Sub
J'ai fais plusieurs tentatives de conversion mais sans vain, voici un éxemple:
SS = Format$(DateDiff("d", -30, Now))
'Text3.Text = ts
s = GetSetting("ooo", "oo", "oo", Text1.Text)
Text1.Text = s
'If Not ts = "" Then
'If ts < Now Then
'MsgBox ts
'Unload Me
'End If
'End If
If Trim$(Text1.Text) = "" Then
Text1.Text = SS
SaveSetting "ooo", "oo", "oo", SS
SaveSetting "ooo", "oo", "osama", Now
End If
COD = GetSetting("OSAMA", "OSAMA", " CODE", Text2.Text)
Text2.Text = COD
Set DB = New ADODB.Connection
Set RS = New ADODB.Recordset
DB.Open "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database password=123; Data Source=" & App.Path & "\database.mdb"
RS.Open "select * from table3", DB, adOpenDynamic, adLockOptimistic
RS.Find "CODE like '" & Text2.Text & "'"
If Not RS.BOF Then
RS!CODE = Text2.Text
s = GetSetting("ooo", "oo", "oo", SS)
Text1.Text = s
Else
MsgBox "Le programme est enregistré, merci!"
Exit Sub
End If
s = GetSetting("ooo", "oo", "oo", SS)
ts = GetSetting("ooo", "oo", "osama", Text3.Text)
Text3.Text = ts
If ts > Now Then
MsgBox "Date introuvable "
Form8.Show
Unload Me
Exit Sub
End If
If s <= Now Then
Dim regm As String
regm = MsgBox("La période d'éssai a expiré, voulez vous enregitrer votre programme?", vbYesNo)
If regm = vbNo Then
Unload Me
Else
Form8.Show
Unload Me
End If
Exit Sub
End If
End Sub
RS.Find "CODE like '" & Text1.Text & "'"
If RS!CODE <> Text1.Text Then
MsgBox "Le code que vous avez entré est faux"
Else
SaveSetting "OSAMA", "OSAMA", " CODE", Text1.Text
MsgBox " Le programme est enregistré, merci "
Unload Me
Form1.Show
End If
merci
Salut,
La méthode find du ADO.Recordset est beaucoup plus pauvre que celle de DAO, je te conseille de faire le travail dans ta requête:
RS.Open "select * from table3 where CODE = '" & Text2.Text & "'", DB, adOpenDynamic, adLockOptimistic
if RS.EOF then pas trouvé