Computing.Net > Forums > Programming > Vb6.0 ado

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Vb6.0 ado

Reply to Message Icon

Name: imtiaz
Date: January 8, 2003 at 14:50:42 Pacific
OS: 98
CPU/Ram: 128
Comment:

hi friend
i am sending a prog in VB6.0. I want to see total number of records in the form of VB. In backend i am using Access
i want a button on form that can tell
me the no of records existing in the table.
Advance Thanks for helping

----
Dim con As New Connection
Dim rs As New Recordset
Dim rsempno As New ADODB.Recordset
Dim rono As Integer
Dim b As Boolean

Private Sub Command1_Click()

On Error Resume Next
rs.MoveNext
If rs.EOF Then
rs.MoveLast
MsgBox "end of file"
End If
getd

End Sub

Private Sub Command2_Click()
rs.MoveLast
getd
End Sub

Private Sub Command3_Click()
rs.MovePrevious

If rs.BOF Then
rs.MoveFirst
MsgBox "beg of file"
End If
getd
End Sub

Private Sub Command4_Click()
rs.MoveFirst
getd
End Sub

Private Sub Command5_Click()
On Error GoTo last


If Text1.Text = "" And Text2.Text = "" And Text3.Text = "" Then
MsgBox "Enter the rollno in the textbox"
Exit Sub
End If
rs.AddNew
rs(0) = Text1.Text
rs(1) = Text2.Text
rs(2) = Val(Text3.Text)
rs.Update
MsgBox "record is updated"

last:
If Err.Number = -2147217887 Then
MsgBox Err.Description
End If

End Sub

Private Sub Command6_Click()
b = True
Text1.Text = ""
Text2 = ""
Text3 = ""
Text1.SetFocus
End Sub

Private Sub Command7_Click()
On Error GoTo last

If MsgBox("Are you sure you want to delete a record", vbYesNo + vbCritical, "Deletion") = vbYes Then
If rs.RecordCount = -1 Then
Text1.Text = ""
MsgBox "No more record exists in the database", vbInformation
End If




rs.Delete
rs.MoveNext
rs.MovePrevious
getd
MsgBox "Record is deleted"
End If

last:
If Err = 3021 Then
MsgBox "No more record exists", vbInformation
End If

End Sub

Private Sub Command8_Click()
If Text1.Text = "" Then
MsgBox "plz select the record for updation"
Exit Sub
End If
'rono = Text1.Text
'rs.Open "select * from std where rollno = " & rono & " ", con, 2, 3

rs(1) = Text2.Text
rs(2) = Val(Text3.Text)

rs.Update
MsgBox "record is updated"

End Sub

Private Sub Form_Load()
On Error GoTo last:
con.Open "provider = microsoft.jet.oledb.4.0;data source = " & App.Path & "\pp.mdb "
rs.Open "select * from std", con, 2, 3


getd

last:
If Err = 3021 Then
MsgBox "No record exists in the table", vbInformation
End If
End Sub
Private Sub getd()
Text1 = rs(0)
Text2 = rs(1) & ""
Text3 = rs(2) & ""
End Sub
Private Sub Text2_GotFocus()

On Error GoTo last
Set rsempno = con.Execute("select rollno from std where rollno = " & Val(Text1.Text) & " ")

If Val(Text1.Text) = rsempno("rollno") And b = True Then
MsgBox "this record already exist"
Text1.SetFocus
End If

last:
If Err.Number = 3021 Then
End If

End Sub



Sponsored Link
Ads by Google

Response Number 1
Name: BelAnWel
Date: January 8, 2003 at 18:04:23 Pacific
Reply:

u already used it: recordcount.

form.caption=rs.recordcount



0

Response Number 2
Name: BelAnWel
Date: January 8, 2003 at 18:06:42 Pacific
Reply:

u already used it: recordcount

form.caption=rs.recordcount

-or-

label.caption=rs.recordcount


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Vb6.0 ado

VB6.0 Data report Problem www.computing.net/answers/programming/vb60-data-report-problem/8205.html

VB6.0 Help www.computing.net/answers/programming/vb60-help-/5230.html

VB6.0 Data Report www.computing.net/answers/programming/vb60-data-report/8509.html