conversion DAO vers ADO

zidane
conversion DAO vers ADO

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:

Dim DB As Database
Dim RS As RecordsetPrivate Sub Form_Load()
 
Dim COD As String
Dim Now As Date
Dim s As String
Dim SS As Date
Now = Date
Dim ts As String
'''''''''''''''''''
''''''''''''''''''
 
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 = CODE
Set DB = OpenDatabase("REGSTED.mdb", False, False, ";pwd=" & "123")
Set RS = DB.OpenRecordset("REG_DATA", 2)
RS.FindFirst "CODE='" + Text2.Text + "'"
If RS.NoMatch Then
 
s = GetSetting("ooo", "oo", "oo", SS)
Text1.Text = s
Else
MsgBox "le programme est enregistré avec succés"
Unload Me
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 "la période d'éssai est terminée"
 
Unload Me
Exit Sub
End If
Dim regm As String
 
regm = MsgBox("la période d'éssai est terminée, voulez vous enregitrer? vbYesNo)
If regm = vbNo Then
Unload Me
Else
FORM2.Show
Unload Me
End If
Exit Sub
 
 
End If

ET sur l'autre forme ou l'utilisateur doit entrer le code, il y'a ce code:
Private Sub Command1_Click()
RS.FindFirst "CODE='" + Text1.Text + "'"
If RS.NoMatch Then
MsgBox "LE code est faux"
Exit Sub
Else
SaveSetting "OSAMA", "OSAMA", " CODE", Text1.Text
MsgBox " ÊLe programme est enregistré "
Unload Me
FORM1.Show

End If
End Sub

J'ai fais plusieurs tentatives de conversion mais sans vain, voici un éxemple:

Dim DB As ADODB.Connection
Dim RS As ADODB.Recordset
Private Sub Form_Load()
Dim COD As String
Dim Now As Date
Dim s As String
Dim SS As Date
Now = Date
Dim ts As String


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

Private Sub Command1_Click()

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
RichardB
Re: conversion DAO vers ADO

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é