How to change "database and User" into CR9 Webservice

  • Thread starter Thread starter Maxi
  • Start date Start date
M

Maxi

Hello, i'm sorry my bad english :(

I have CR9 Webservice, how to change databadse name and User_name into
Webservice method? (not Viewer Control)

Tks!!
 
Hi, tks for link :-)

The Sample is not use Webservice :(, the sample use Client pass Parameter :(

How to into webservice change Database? Example:


Client (WF) -- > WS --> Report

Client Pass the parameters for Connection to WS.

I Want Connection setting into WS only, and Client consume WS only

it understands to me?

Tks
 
Hi, can't you use the crpConnectionInfo part from the link, inside the
webservice?

I hope this helps

Greetz Peter



'Part from the sample
With crpConnectionInfo
.ServerName = strServer
.DatabaseName = strDataBase
End With
'If you don't use integrated security
'provide the username and password used to logon to the database
If blnIntegrated = False Then
crpConnectionInfo.UserID = strUserId
crpConnectionInfo.Password = strPassword
End If

'Apply the ConnectionloginInfo to every table that's used inside the
report
For Each tblCurrent In crReportDocument.Database.Tables
crpTableLogOnInfo = tblCurrent.LogOnInfo
crpTableLogOnInfo.ConnectionInfo = crpConnectionInfo
tblCurrent.ApplyLogOnInfo(crpTableLogOnInfo)
Next

'Set the sections collection with report sections
crSections = crReportDocument.ReportDefinition.Sections
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
For Each crReportObject In crReportObjects
If crReportObject.Kind = ReportObjectKind.SubreportObject
Then
'If there's a subreport, typecast the reportobject to a
subreport object
crSubreportObject = CType(crReportObject,
SubreportObject)

'Open the subreport
subRepDoc =
crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

crDatabase = subRepDoc.Database
crTables = crDatabase.Tables

'Loop through all the tables and set the connection
info,
'Pass on the connection info to the logoninfo object
then add the
'logoninfo to the subreport
For Each crTable In crTables
With crpConnectionInfo
.ServerName = strServer
.DatabaseName = strDataBase
End With
crLogOnInfo = crTable.LogOnInfo
crLogOnInfo.ConnectionInfo = crpConnectionInfo
crTable.ApplyLogOnInfo(crLogOnInfo)
Next
End If
Next
Next

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

Maxi said:
Hi, tks for link :-)

The Sample is not use Webservice :(, the sample use Client pass Parameter :(

How to into webservice change Database? Example:


Client (WF) -- > WS --> Report

Client Pass the parameters for Connection to WS.

I Want Connection setting into WS only, and Client consume WS only

it understands to me?

Tks


--

--------------------------
Salu2
Maxi [MVP SQL SERVER]
www.sqlgurus.org


Peter Proost said:
Hi maybe this example can help you, it's a vb.net sample but could help
you

http://www.vb-tips.com/default.aspx?ID=68888abf-f137-45d1-8a81-e779bfb411c5

Greetz Peter
 
Hi, tks!!

My Webservice code is:

Public Sub New()


Me.ReportSource = Me.Server.MapPath("CR1.rpt")


End Sub

Where insert your code?

--

--------------------------
Salu2
Maxi [MVP SQL SERVER]
www.sqlgurus.org


Peter Proost said:
Hi, can't you use the crpConnectionInfo part from the link, inside the
webservice?

I hope this helps

Greetz Peter



'Part from the sample
With crpConnectionInfo
.ServerName = strServer
.DatabaseName = strDataBase
End With
'If you don't use integrated security
'provide the username and password used to logon to the database
If blnIntegrated = False Then
crpConnectionInfo.UserID = strUserId
crpConnectionInfo.Password = strPassword
End If

'Apply the ConnectionloginInfo to every table that's used inside
the
report
For Each tblCurrent In crReportDocument.Database.Tables
crpTableLogOnInfo = tblCurrent.LogOnInfo
crpTableLogOnInfo.ConnectionInfo = crpConnectionInfo
tblCurrent.ApplyLogOnInfo(crpTableLogOnInfo)
Next

'Set the sections collection with report sections
crSections = crReportDocument.ReportDefinition.Sections
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
For Each crReportObject In crReportObjects
If crReportObject.Kind = ReportObjectKind.SubreportObject
Then
'If there's a subreport, typecast the reportobject to a
subreport object
crSubreportObject = CType(crReportObject,
SubreportObject)

'Open the subreport
subRepDoc =
crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

crDatabase = subRepDoc.Database
crTables = crDatabase.Tables

'Loop through all the tables and set the connection
info,
'Pass on the connection info to the logoninfo object
then add the
'logoninfo to the subreport
For Each crTable In crTables
With crpConnectionInfo
.ServerName = strServer
.DatabaseName = strDataBase
End With
crLogOnInfo = crTable.LogOnInfo
crLogOnInfo.ConnectionInfo = crpConnectionInfo
crTable.ApplyLogOnInfo(crLogOnInfo)
Next
End If
Next
Next

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

Maxi said:
Hi, tks for link :-)

The Sample is not use Webservice :(, the sample use Client pass Parameter :(

How to into webservice change Database? Example:


Client (WF) -- > WS --> Report

Client Pass the parameters for Connection to WS.

I Want Connection setting into WS only, and Client consume WS only

it understands to me?

Tks


--

--------------------------
Salu2
Maxi [MVP SQL SERVER]
www.sqlgurus.org


Peter Proost said:
Hi maybe this example can help you, it's a vb.net sample but could help
you

http://www.vb-tips.com/default.aspx?ID=68888abf-f137-45d1-8a81-e779bfb411c5

Greetz Peter

--
Programming today is a race between software engineers striving to
build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Maxi" <[email protected]> schreef in bericht
Hello, i'm sorry my bad english :(

I have CR9 Webservice, how to change databadse name and User_name into
Webservice method? (not Viewer Control)

Tks!!
 
Public Sub New()


Me.ReportSource = Me.Server.MapPath("CR1.rpt")


End Sub


--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

Maxi said:
Hi, tks!!

My Webservice code is:

Public Sub New()


Me.ReportSource = Me.Server.MapPath("CR1.rpt")


End Sub

Where insert your code?

--

--------------------------
Salu2
Maxi [MVP SQL SERVER]
www.sqlgurus.org


Peter Proost said:
Hi, can't you use the crpConnectionInfo part from the link, inside the
webservice?

I hope this helps

Greetz Peter



'Part from the sample
With crpConnectionInfo
.ServerName = strServer
.DatabaseName = strDataBase
End With
'If you don't use integrated security
'provide the username and password used to logon to the database
If blnIntegrated = False Then
crpConnectionInfo.UserID = strUserId
crpConnectionInfo.Password = strPassword
End If

'Apply the ConnectionloginInfo to every table that's used inside
the
report
For Each tblCurrent In crReportDocument.Database.Tables
crpTableLogOnInfo = tblCurrent.LogOnInfo
crpTableLogOnInfo.ConnectionInfo = crpConnectionInfo
tblCurrent.ApplyLogOnInfo(crpTableLogOnInfo)
Next

'Set the sections collection with report sections
crSections = crReportDocument.ReportDefinition.Sections
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
For Each crReportObject In crReportObjects
If crReportObject.Kind = ReportObjectKind.SubreportObject
Then
'If there's a subreport, typecast the reportobject to a
subreport object
crSubreportObject = CType(crReportObject,
SubreportObject)

'Open the subreport
subRepDoc =
crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

crDatabase = subRepDoc.Database
crTables = crDatabase.Tables

'Loop through all the tables and set the connection
info,
'Pass on the connection info to the logoninfo object
then add the
'logoninfo to the subreport
For Each crTable In crTables
With crpConnectionInfo
.ServerName = strServer
.DatabaseName = strDataBase
End With
crLogOnInfo = crTable.LogOnInfo
crLogOnInfo.ConnectionInfo = crpConnectionInfo
crTable.ApplyLogOnInfo(crLogOnInfo)
Next
End If
Next
Next

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

Maxi said:
Hi, tks for link :-)

The Sample is not use Webservice :(, the sample use Client pass
Parameter
:(
How to into webservice change Database? Example:


Client (WF) -- > WS --> Report

Client Pass the parameters for Connection to WS.

I Want Connection setting into WS only, and Client consume WS only

it understands to me?

Tks


--

--------------------------
Salu2
Maxi [MVP SQL SERVER]
www.sqlgurus.org


"Peter Proost" <[email protected]> escribió en el mensaje
Hi maybe this example can help you, it's a vb.net sample but could help
you
http://www.vb-tips.com/default.aspx?ID=68888abf-f137-45d1-8a81-e779bfb411c5
Greetz Peter

--
Programming today is a race between software engineers striving to
build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Maxi" <[email protected]> schreef in bericht
Hello, i'm sorry my bad english :(

I have CR9 Webservice, how to change databadse name and User_name into
Webservice method? (not Viewer Control)

Tks!!
 
Sorry about the previous post, I acedently pressed send

I think this code should help you, I paste my code in your sub new, I hope
it's clear to you

If you use a crReportDocument in windows form app you also need to call
crReportDocument.Dispose() when the form closes. I don't know if this is
also necessary with a webservice, but I think so.

Greetz Peter

'you need to add a reference to these 3 dll's

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.ReportSource

'The variable containing the report
Private crReportDocument As ReportDocument


Public Sub New()

Dim tblCurrent As Table
Dim crSubreportObject As SubreportObject
Dim subRepDoc As New ReportDocument
Dim crDatabase As CrystalDecisions.CrystalReports.Engine.Database
Dim crTables As Tables
Dim crTable As Table
Dim crSection As Section
Dim crSections As Sections
Dim crReportObjects As ReportObjects
Dim crReportObject As ReportObject
Dim crLogOnInfo As TableLogOnInfo
Dim crpConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo
Dim crpTableLogOnInfo As New CrystalDecisions.Shared.TableLogOnInfo


crReportDocument = New ReportDocument

crReportDocument.Load(Me.Server.MapPath("CR1.rpt"))
Me.ReportSource = crReportDocument

With crpConnectionInfo
.ServerName = "Server"
.DatabaseName = "Database'
End With
'If you don't use integrated security
'provide the username and password used to logon to the database

crpConnectionInfo.UserID = "user"
crpConnectionInfo.Password = "password"

'Apply the ConnectionloginInfo to every table that's used inside the report
For Each tblCurrent In crReportDocument.Database.Tables
crpTableLogOnInfo = tblCurrent.LogOnInfo
crpTableLogOnInfo.ConnectionInfo = crpConnectionInfo
tblCurrent.ApplyLogOnInfo(crpTableLogOnInfo)
Next

'if there are subreports they also need the correct logon info
'Set the sections collection with report sections
crSections = crReportDocument.ReportDefinition.Sections
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
For Each crReportObject In crReportObjects
If crReportObject.Kind = ReportObjectKind.SubreportObject
Then
'If there's a subreport, typecast the reportobject to a
subreport object
crSubreportObject = CType(crReportObject,
SubreportObject)

'Open the subreport
subRepDoc =
crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

crDatabase = subRepDoc.Database
crTables = crDatabase.Tables

'Loop through all the tables and set the connection
info,
'Pass on the connection info to the logoninfo object
then add the
'logoninfo to the subreport
For Each crTable In crTables
With crpConnectionInfo
.ServerName = strServer
.DatabaseName = strDataBase
End With
crLogOnInfo = crTable.LogOnInfo
crLogOnInfo.ConnectionInfo = crpConnectionInfo
crTable.ApplyLogOnInfo(crLogOnInfo)
Next
End If
Next
Next


End Sub


--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

Maxi said:
Hi, tks!!

My Webservice code is:

Public Sub New()


Me.ReportSource = Me.Server.MapPath("CR1.rpt")


End Sub

Where insert your code?

--

--------------------------
Salu2
Maxi [MVP SQL SERVER]
www.sqlgurus.org


Peter Proost said:
Hi, can't you use the crpConnectionInfo part from the link, inside the
webservice?

I hope this helps

Greetz Peter



'Part from the sample
With crpConnectionInfo
.ServerName = strServer
.DatabaseName = strDataBase
End With
'If you don't use integrated security
'provide the username and password used to logon to the database
If blnIntegrated = False Then
crpConnectionInfo.UserID = strUserId
crpConnectionInfo.Password = strPassword
End If

'Apply the ConnectionloginInfo to every table that's used inside
the
report
For Each tblCurrent In crReportDocument.Database.Tables
crpTableLogOnInfo = tblCurrent.LogOnInfo
crpTableLogOnInfo.ConnectionInfo = crpConnectionInfo
tblCurrent.ApplyLogOnInfo(crpTableLogOnInfo)
Next

'Set the sections collection with report sections
crSections = crReportDocument.ReportDefinition.Sections
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
For Each crReportObject In crReportObjects
If crReportObject.Kind = ReportObjectKind.SubreportObject
Then
'If there's a subreport, typecast the reportobject to a
subreport object
crSubreportObject = CType(crReportObject,
SubreportObject)

'Open the subreport
subRepDoc =
crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

crDatabase = subRepDoc.Database
crTables = crDatabase.Tables

'Loop through all the tables and set the connection
info,
'Pass on the connection info to the logoninfo object
then add the
'logoninfo to the subreport
For Each crTable In crTables
With crpConnectionInfo
.ServerName = strServer
.DatabaseName = strDataBase
End With
crLogOnInfo = crTable.LogOnInfo
crLogOnInfo.ConnectionInfo = crpConnectionInfo
crTable.ApplyLogOnInfo(crLogOnInfo)
Next
End If
Next
Next

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

Maxi said:
Hi, tks for link :-)

The Sample is not use Webservice :(, the sample use Client pass
Parameter
:(
How to into webservice change Database? Example:


Client (WF) -- > WS --> Report

Client Pass the parameters for Connection to WS.

I Want Connection setting into WS only, and Client consume WS only

it understands to me?

Tks


--

--------------------------
Salu2
Maxi [MVP SQL SERVER]
www.sqlgurus.org


"Peter Proost" <[email protected]> escribió en el mensaje
Hi maybe this example can help you, it's a vb.net sample but could help
you
http://www.vb-tips.com/default.aspx?ID=68888abf-f137-45d1-8a81-e779bfb411c5
Greetz Peter

--
Programming today is a race between software engineers striving to
build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Maxi" <[email protected]> schreef in bericht
Hello, i'm sorry my bad english :(

I have CR9 Webservice, how to change databadse name and User_name into
Webservice method? (not Viewer Control)

Tks!!
 
Tks!! Excelent!!! :-))))


--

--------------------------
Salu2
Maxi [MVP SQL SERVER]
www.sqlgurus.org


Peter Proost said:
Sorry about the previous post, I acedently pressed send

I think this code should help you, I paste my code in your sub new, I hope
it's clear to you

If you use a crReportDocument in windows form app you also need to call
crReportDocument.Dispose() when the form closes. I don't know if this is
also necessary with a webservice, but I think so.

Greetz Peter

'you need to add a reference to these 3 dll's

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.ReportSource

'The variable containing the report
Private crReportDocument As ReportDocument


Public Sub New()

Dim tblCurrent As Table
Dim crSubreportObject As SubreportObject
Dim subRepDoc As New ReportDocument
Dim crDatabase As CrystalDecisions.CrystalReports.Engine.Database
Dim crTables As Tables
Dim crTable As Table
Dim crSection As Section
Dim crSections As Sections
Dim crReportObjects As ReportObjects
Dim crReportObject As ReportObject
Dim crLogOnInfo As TableLogOnInfo
Dim crpConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo
Dim crpTableLogOnInfo As New CrystalDecisions.Shared.TableLogOnInfo


crReportDocument = New ReportDocument

crReportDocument.Load(Me.Server.MapPath("CR1.rpt"))
Me.ReportSource = crReportDocument

With crpConnectionInfo
.ServerName = "Server"
.DatabaseName = "Database'
End With
'If you don't use integrated security
'provide the username and password used to logon to the database

crpConnectionInfo.UserID = "user"
crpConnectionInfo.Password = "password"

'Apply the ConnectionloginInfo to every table that's used inside the
report
For Each tblCurrent In crReportDocument.Database.Tables
crpTableLogOnInfo = tblCurrent.LogOnInfo
crpTableLogOnInfo.ConnectionInfo = crpConnectionInfo
tblCurrent.ApplyLogOnInfo(crpTableLogOnInfo)
Next

'if there are subreports they also need the correct logon info
'Set the sections collection with report sections
crSections = crReportDocument.ReportDefinition.Sections
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
For Each crReportObject In crReportObjects
If crReportObject.Kind = ReportObjectKind.SubreportObject
Then
'If there's a subreport, typecast the reportobject to a
subreport object
crSubreportObject = CType(crReportObject,
SubreportObject)

'Open the subreport
subRepDoc =
crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

crDatabase = subRepDoc.Database
crTables = crDatabase.Tables

'Loop through all the tables and set the connection
info,
'Pass on the connection info to the logoninfo object
then add the
'logoninfo to the subreport
For Each crTable In crTables
With crpConnectionInfo
.ServerName = strServer
.DatabaseName = strDataBase
End With
crLogOnInfo = crTable.LogOnInfo
crLogOnInfo.ConnectionInfo = crpConnectionInfo
crTable.ApplyLogOnInfo(crLogOnInfo)
Next
End If
Next
Next


End Sub


--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

Maxi said:
Hi, tks!!

My Webservice code is:

Public Sub New()


Me.ReportSource = Me.Server.MapPath("CR1.rpt")


End Sub

Where insert your code?

--

--------------------------
Salu2
Maxi [MVP SQL SERVER]
www.sqlgurus.org


Peter Proost said:
Hi, can't you use the crpConnectionInfo part from the link, inside the
webservice?

I hope this helps

Greetz Peter



'Part from the sample
With crpConnectionInfo
.ServerName = strServer
.DatabaseName = strDataBase
End With
'If you don't use integrated security
'provide the username and password used to logon to the database
If blnIntegrated = False Then
crpConnectionInfo.UserID = strUserId
crpConnectionInfo.Password = strPassword
End If

'Apply the ConnectionloginInfo to every table that's used inside
the
report
For Each tblCurrent In crReportDocument.Database.Tables
crpTableLogOnInfo = tblCurrent.LogOnInfo
crpTableLogOnInfo.ConnectionInfo = crpConnectionInfo
tblCurrent.ApplyLogOnInfo(crpTableLogOnInfo)
Next

'Set the sections collection with report sections
crSections = crReportDocument.ReportDefinition.Sections
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
For Each crReportObject In crReportObjects
If crReportObject.Kind =
ReportObjectKind.SubreportObject
Then
'If there's a subreport, typecast the reportobject
to a
subreport object
crSubreportObject = CType(crReportObject,
SubreportObject)

'Open the subreport
subRepDoc =
crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

crDatabase = subRepDoc.Database
crTables = crDatabase.Tables

'Loop through all the tables and set the connection
info,
'Pass on the connection info to the logoninfo object
then add the
'logoninfo to the subreport
For Each crTable In crTables
With crpConnectionInfo
.ServerName = strServer
.DatabaseName = strDataBase
End With
crLogOnInfo = crTable.LogOnInfo
crLogOnInfo.ConnectionInfo = crpConnectionInfo
crTable.ApplyLogOnInfo(crLogOnInfo)
Next
End If
Next
Next

--
Programming today is a race between software engineers striving to
build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Maxi" <[email protected]> schreef in bericht
Hi, tks for link :-)

The Sample is not use Webservice :(, the sample use Client pass Parameter
:(

How to into webservice change Database? Example:


Client (WF) -- > WS --> Report

Client Pass the parameters for Connection to WS.

I Want Connection setting into WS only, and Client consume WS only

it understands to me?

Tks


--

--------------------------
Salu2
Maxi [MVP SQL SERVER]
www.sqlgurus.org


"Peter Proost" <[email protected]> escribió en el mensaje
Hi maybe this example can help you, it's a vb.net sample but could help
you


http://www.vb-tips.com/default.aspx?ID=68888abf-f137-45d1-8a81-e779bfb411c5

Greetz Peter

--
Programming today is a race between software engineers striving to
build
bigger and better idiot-proof programs, and the Universe trying to
produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Maxi" <[email protected]> schreef in bericht
Hello, i'm sorry my bad english :(

I have CR9 Webservice, how to change databadse name and User_name into
Webservice method? (not Viewer Control)

Tks!!
 
Glad to help

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

Maxi said:
Tks!! Excelent!!! :-))))


--

--------------------------
Salu2
Maxi [MVP SQL SERVER]
www.sqlgurus.org


Peter Proost said:
Sorry about the previous post, I acedently pressed send

I think this code should help you, I paste my code in your sub new, I hope
it's clear to you

If you use a crReportDocument in windows form app you also need to call
crReportDocument.Dispose() when the form closes. I don't know if this is
also necessary with a webservice, but I think so.

Greetz Peter

'you need to add a reference to these 3 dll's

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.ReportSource

'The variable containing the report
Private crReportDocument As ReportDocument


Public Sub New()

Dim tblCurrent As Table
Dim crSubreportObject As SubreportObject
Dim subRepDoc As New ReportDocument
Dim crDatabase As CrystalDecisions.CrystalReports.Engine.Database
Dim crTables As Tables
Dim crTable As Table
Dim crSection As Section
Dim crSections As Sections
Dim crReportObjects As ReportObjects
Dim crReportObject As ReportObject
Dim crLogOnInfo As TableLogOnInfo
Dim crpConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo
Dim crpTableLogOnInfo As New CrystalDecisions.Shared.TableLogOnInfo


crReportDocument = New ReportDocument

crReportDocument.Load(Me.Server.MapPath("CR1.rpt"))
Me.ReportSource = crReportDocument

With crpConnectionInfo
.ServerName = "Server"
.DatabaseName = "Database'
End With
'If you don't use integrated security
'provide the username and password used to logon to the database

crpConnectionInfo.UserID = "user"
crpConnectionInfo.Password = "password"

'Apply the ConnectionloginInfo to every table that's used inside the
report
For Each tblCurrent In crReportDocument.Database.Tables
crpTableLogOnInfo = tblCurrent.LogOnInfo
crpTableLogOnInfo.ConnectionInfo = crpConnectionInfo
tblCurrent.ApplyLogOnInfo(crpTableLogOnInfo)
Next

'if there are subreports they also need the correct logon info
'Set the sections collection with report sections
crSections = crReportDocument.ReportDefinition.Sections
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
For Each crReportObject In crReportObjects
If crReportObject.Kind = ReportObjectKind.SubreportObject
Then
'If there's a subreport, typecast the reportobject to a
subreport object
crSubreportObject = CType(crReportObject,
SubreportObject)

'Open the subreport
subRepDoc =
crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

crDatabase = subRepDoc.Database
crTables = crDatabase.Tables

'Loop through all the tables and set the connection
info,
'Pass on the connection info to the logoninfo object
then add the
'logoninfo to the subreport
For Each crTable In crTables
With crpConnectionInfo
.ServerName = strServer
.DatabaseName = strDataBase
End With
crLogOnInfo = crTable.LogOnInfo
crLogOnInfo.ConnectionInfo = crpConnectionInfo
crTable.ApplyLogOnInfo(crLogOnInfo)
Next
End If
Next
Next


End Sub


--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

Maxi said:
Hi, tks!!

My Webservice code is:

Public Sub New()


Me.ReportSource = Me.Server.MapPath("CR1.rpt")


End Sub

Where insert your code?

--

--------------------------
Salu2
Maxi [MVP SQL SERVER]
www.sqlgurus.org


"Peter Proost" <[email protected]> escribió en el mensaje
Hi, can't you use the crpConnectionInfo part from the link, inside the
webservice?

I hope this helps

Greetz Peter



'Part from the sample
With crpConnectionInfo
.ServerName = strServer
.DatabaseName = strDataBase
End With
'If you don't use integrated security
'provide the username and password used to logon to the database
If blnIntegrated = False Then
crpConnectionInfo.UserID = strUserId
crpConnectionInfo.Password = strPassword
End If

'Apply the ConnectionloginInfo to every table that's used inside
the
report
For Each tblCurrent In crReportDocument.Database.Tables
crpTableLogOnInfo = tblCurrent.LogOnInfo
crpTableLogOnInfo.ConnectionInfo = crpConnectionInfo
tblCurrent.ApplyLogOnInfo(crpTableLogOnInfo)
Next

'Set the sections collection with report sections
crSections = crReportDocument.ReportDefinition.Sections
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
For Each crReportObject In crReportObjects
If crReportObject.Kind =
ReportObjectKind.SubreportObject
Then
'If there's a subreport, typecast the reportobject
to a
subreport object
crSubreportObject = CType(crReportObject,
SubreportObject)

'Open the subreport
subRepDoc =
crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

crDatabase = subRepDoc.Database
crTables = crDatabase.Tables

'Loop through all the tables and set the connection
info,
'Pass on the connection info to the logoninfo object
then add the
'logoninfo to the subreport
For Each crTable In crTables
With crpConnectionInfo
.ServerName = strServer
.DatabaseName = strDataBase
End With
crLogOnInfo = crTable.LogOnInfo
crLogOnInfo.ConnectionInfo = crpConnectionInfo
crTable.ApplyLogOnInfo(crLogOnInfo)
Next
End If
Next
Next

--
Programming today is a race between software engineers striving to
build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Maxi" <[email protected]> schreef in bericht
Hi, tks for link :-)

The Sample is not use Webservice :(, the sample use Client pass Parameter
:(

How to into webservice change Database? Example:


Client (WF) -- > WS --> Report

Client Pass the parameters for Connection to WS.

I Want Connection setting into WS only, and Client consume WS only

it understands to me?

Tks


--

--------------------------
Salu2
Maxi [MVP SQL SERVER]
www.sqlgurus.org


"Peter Proost" <[email protected]> escribió en el mensaje
Hi maybe this example can help you, it's a vb.net sample but could help
you
http://www.vb-tips.com/default.aspx?ID=68888abf-f137-45d1-8a81-e779bfb411c5
Greetz Peter

--
Programming today is a race between software engineers striving to
build
bigger and better idiot-proof programs, and the Universe trying to
produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Maxi" <[email protected]> schreef in bericht
Hello, i'm sorry my bad english :(

I have CR9 Webservice, how to change databadse name and User_name into
Webservice method? (not Viewer Control)

Tks!!
 
Back
Top