MySQL Forums
Forum List  »  Newbie

MYSQL5-VB6- MOVENEXT, FIRST, PREVIOUS, LAST
Posted by: Flavio Jr
Date: March 17, 2007 04:05PM

I need some help the movefirst, previous, next, last don't work on the form in other words the next record don't appear on the textbox:

this is my code in the module.

Option Explicit

Public cn As ADODB.Connection
Public rsMySQL As ADODB.Recordset
Public SQL As String
Public ConectaMySQL As String

Public Sub DBAtivo()

'DoEvents
Set cn = New ADODB.Connection
' Set rsMySQL = New ADODB.Recordset

'Set cn = CreateObject("ADODB.Connection")

ConectaMySQL = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=sunrise_db;User=root;Password=flaviojr;Option=3;"

cn.CursorLocation = adUseClient

cn.Open ConectaMySQL

Set rsMySQL = CreateObject("ADODB.Recordset")

'Set rsMySQL = New ADODB.Recordset

'Prepara o recordset
rsMySQL.CursorType = adOpenStatic

rsMySQL.CursorLocation = adUseClient

rsMySQL.LockType = adLockPessimistic

rsMySQL.ActiveConnection = cn


End Sub


Public Sub DBFechar()

Set cn = Nothing 'close up the connection
If rsMySQL Is Nothing Then Else rsMySQL.Close
Set rsMySQL = Nothing

End Sub

and the code in the form:

Private Sub cmdNext_Click()

If Not rsMySQL.EOF Then rsMySQL.MoveNext
If rsMySQL.EOF And rsMySQL.RecordCount > 0 Then
Beep
rsMySQL.MoveLast
MsgBox "This is the last record.", _
vbInformation, "Last Record"
End If


End Sub

Private Sub Command7_Click()
Call DBFechar
Unload Me
End Sub

Private Sub Form_Load()


Call DBAtivo

SQL = "SELECT * FROM tb_alunos"
rsMySQL.Open SQL, ConectaMySQL
Set rsMySQL = cn.Execute(SQL)



txtNome.Text = rsMySQL!Nome


End Sub

Options: ReplyQuote


Subject
Written By
Posted
MYSQL5-VB6- MOVENEXT, FIRST, PREVIOUS, LAST
March 17, 2007 04:05PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.