Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

about addadocommand

Status
Not open for further replies.

origine

Programmer
Joined
Aug 1, 2001
Messages
1
Location
TN
i'am trying to create a dynamic report with crystal report 8.0 devlopper version but i couldn't find any example using sql server 2000 database.

i want to pass an sql string with the

adoaddcommand pconnection,padocommand

my code is looking like this :

Private Sub cmdADO_Click()
Dim fld As FieldObject
Dim strCnn As String

' Open the data connection
Set cnn1 = New ADODB.Connection
strCnn = "Provider=SQLOLEDB.1;UID=sa;PWD=password;User ID=sa;Initial Catalog=databasename;DataSource=servername"

cnn1.Open strCnn

' Create a new instance of an ADO command object
Set datcmd1 = New ADODB.Command
Set datcmd1.ActiveConnection = cnn1
datcmd1.CommandText = "select * from TableName"
datcmd1.CommandType = adCmdText

' Add the datasource to the report
m_Report.Database.AddADOCommand cnn1, datcmd1
' Add a new field object to the report and set the field object to use
' the new data source.
Set fld = m_Report.Section3.AddFieldObject("{ado.TableName FieldName}", 0, 0)
LoadReport
End Sub

but i got a runtime error : argument ou appel de procedure incorrect

this message is in french because i have vb 6 french edition

can you help me to find a way for working with sql server 2000 database, if you can send a little sample i would be greatful

sincerely ben alaya mohsen.
 
Origine:

I have had that same problem in the past. A small change to your code should get this to work.

First... open a recordset object like so:
someRS.open [your command object]

Then, modify your addadocommand call:
m_Report.Database.AddADOCommand someRS.ActiveConnection, someRS.ActiveCommand

I'm not sure why you need this particular syntax for it to work or why passing a standard connection object and command object to the method bombs out.

By the way, this particular way of changing the data source of a report, at run-time, only seems to work when your recordset is created by a SQL string. If you create the recordset from a stored procedure, you will get the error -2147192179 (8004728d) Error detected by database dll. This particular error is a known issue and has yet to be solved.
 
in fact i am doing the same thing as you do. but my problem is: i tried to create the recordset from a stored procedure. however, it doesn't work. the error message-2147192179(8004728d) always shown. do you know how to solved this problem?

thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top