HI
I am Fazeel Amjad experienced in designing data driven application with Visual Basic and SQL Server 2000/2005.
I am writing here an example for you.
It is assumed that you have a table named Products with these fields
ProductID, ProductName, QtyInStock, SalePrice
it is also assumed that you have setup a datareport with above named fields to display reports. never forget to the set the Datafield value of fields in detail section of the datareport. the datafield value will be the fields in query i.e. productid, productname etc.
Private Function PrintProductsInStock()
Dim SQL as String
Dim Conn as ADODB.Connection
Dim Rs as New ADODB.Recordset
' you must setup Conn parameters to connect to the db. i.e. connection string
If Conn.State = adStateClosed Then Conn.Open
SQL="SELECT ProductID, ProductName, QtyInStock, SalePrice From Products Where QtyInStock>0"
SET Rs=Conn.Execute(SQL)
If Rs.EOF<>True then
rptProducts.Datasource=Rs
else
msgbox "No record found.",vbCritical
exit function
End If
rptProducts.Refresh
rptProducts.Show
End Function
Hope this will solve your problem.
If you need my further help here is my contact info.
Fazeel Amjad
CEO
(Artis Interactive)
Pakistan
Mob: 0092-333-7439717
email: fazeel.amjad@gmail.com