Ans:
Dim con As New ADODB.Connection
Dim brs As New ADODB. Recordset
Private Sub Command1_Click()
If brs.State = adStateOpen Then
brs.Close
End If
brs.Open "select * from bloodgroupdetails where blood_group = '" &
Combo1.Text & "'", con, adOpenDynamic, adLockBatchOptimistic
If (brs.BOF = True And brs.EOF = True) Then
MsgBox "Record Not Found"
Else
Set DataReport2.DataSource = brs
DataReport2.Sections("Section1") .Controls (1) .DataField =
brs. Fields(0).Name
DataReport2. Sections("Section1") .Controls(2) .DataField =
brs. Fields (1) . Name
DataReport2. Sections("Section1") .Controls(3) .DataField =
brs. Fields(2) .Name
DataReport2.Sections("Section1") .Controls(4) .DataField =
brs. Fields(3). Name
DataReport2. Sections("Section1") .Controls(5) .DataField =
brs. Fields (4).Name
DataReport2.Show
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
If con.State = adStateOpen Then
con.Close
End If
con.Open "Provider = Microsoft.Jet.OLEDB.4.0;Data
Source=E:\ASSINGMENT\bloodreport.mdb;Persist Security Info=False"
If brs.State = adStateOpen Then
brs.Close
End If
If brs. State = adStateOpen Then
brs.Close
End If
brs.Open "select * from bloodgroupdetails", con, adOpenDynamic,
adLockBatchOptimistic
End Sub
No comments:
Post a Comment