|
-
Nov 13th, 2005, 04:57 AM
#1
Thread Starter
Member
Datareport Dumie
Hi all
I have this code
VB Code:
Private Sub Form_Load()
' **** Create Connection and Recordset Objects ****
Dim cnConn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strsql As String
' **** Instantiate the new objects ****
Set cnConn = New ADODB.Connection
Set rs = New ADODB.Recordset
' **** Set up connection String ****
With cnConn
.Provider = "SQLOLEDB.1"
.Properties("Data Source").Value = "www"
.Properties("User ID").Value = "clroot"
.Properties("Password").Value = "clroot"
.Properties("Initial Catalog").Value = "iosif"
.CursorLocation = adUseClient
.ConnectionTimeout = 0
.Open
End With
' **** String to pass to the connection to get records back ****
strsql = "select * from salesman"
' **** Open Records for readonly ****
rs.Open strsql, cnConn, adOpenStatic, adLockReadOnly
How I can pass values from table salesman into a datareport1?
thank you
Edit: Added [vbcode][/vbcode] tags for more clarity. - Hack
Last edited by Hack; Nov 14th, 2005 at 01:22 PM.
-
Nov 14th, 2005, 01:23 PM
#2
Re: Datareport Dumie
Moved to reporting section.
-
Nov 14th, 2005, 05:45 PM
#3
Re: Datareport Dumie
You must set the DataField property of each control on the report equal to a field name in the recordset. This can be done at runtime or designtime.
I added the code required to set the datareport's datasource to the recordset.
VB Code:
Private Sub Form_Load()
' **** Create Connection and Recordset Objects ****
Dim cnConn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strsql As String
' **** Instantiate the new objects ****
Set cnConn = New ADODB.Connection
Set rs = New ADODB.Recordset
' **** Set up connection String ****
With cnConn
.Provider = "SQLOLEDB.1"
.Properties("Data Source").Value = "www"
.Properties("User ID").Value = "clroot"
.Properties("Password").Value = "clroot"
.Properties("Initial Catalog").Value = "iosif"
.CursorLocation = adUseClient
.ConnectionTimeout = 0
.Open
End With
' **** String to pass to the connection to get records back ****
strsql = "select * from salesman"
' **** Open Records for readonly ****
rs.Open strsql, cnConn, adOpenStatic, adLockReadOnly
[B]'Disconnect recordset from db
Set rs.ActiveConnection = Nothing
db.close
set db = nothing
Load DataReport1
Set DataReport1.DataSource = rs
DataReport1.Show
set rs = Nothing[/B]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|