1 Replies - 6198 Views - Last Post: 19 June 2010 - 02:27 PM Rate Topic: -----

#1 Victorybiz  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 5
  • Joined: 04-April 10

VB6.0: Searching and reporting a particular record from database

Posted 19 June 2010 - 03:17 AM

This Code segment enable you to connect to database, search and and report a particular record from database.
Private Sub Cmdfind_click()
Dim con as ADODB.Connection
Dim rs as ADODB.RecordSet
Set con = New ADODB.Connection
Set rs = New ADODB.RecordSet
con.Open "Connection String"
con.CursorLocation = AdUserClient
rs.Open "SELECT *FROM tablenameToSearchfrom WHERE FieldnameToSearchfrom= ' " &text1.text(thetxtboxTosearchwith)& " ' ", con, OpenDynamic, AdOptimistic
if rs.EOF = False and rs.BOF = False Then
labelname.caption = rs!fieldname in database eg. rs!name
labelsex.caption = rs!sex
labelMatNo.caption= rs!matno
Else
Msgbox "Record not found", vbCritical + vbOkOnly, "Error"
End If
End Sub
'To get connection string, goto component insert ADO data Control, place it on the form, the right click, select properties. Follow procedure till test connection, then copy the connection string and paste.

Is This A Good Question/Topic? 1
  • +

Replies To: VB6.0: Searching and reporting a particular record from database

#2 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: VB6.0: Searching and reporting a particular record from database

Posted 19 June 2010 - 02:27 PM

ok! is that your question? or did you try post a snippet,
if you try to post a codesnippet then post it in vb code snippet portion in the snippets section
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1