D
douglas
I am having a problem with a connection string. Right after the crystal
report opens, it asks me for connection information. This is happening since
I have windows authenication on my desktop (when running the vb.net
application) but I have sql server authenication only once The crystal report
is running. Thus can you tell me how to pass in the sql server authenication
once the crystal report opens up? Here is my code right now:
Dim cryRpt As New ReportDocument
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim cryRpt As New ReportDocument
Dim sql As String
Dim connetionString As String
Dim connection As SqlConnection
Dim connetionString2 As String
Dim connection2 As SqlConnection
Dim adapter As SqlDataAdapter
Dim ds As New DataSet
'located crystal report from
Dim strReportPath As String = "C:\test.rpt"
connetionString = "Data Source=server name,1433;Initial
Catalog=databasename;User ID=id;Password=sss"
connection = New SqlConnection(connetionString)
'sql = "select * from testtable
connection.Open()
adapter = New SqlDataAdapter(sql, connection)
adapter.Fill(ds)
connection.Close()
Try
For i = 0 To ds.Tables(0).Rows.Count - 1
'for get individual columns in a table
'dt = ds.Tables(0)
'For i = 0 To dt.Columns.Count - 1
' MsgBox(dt.Columns(i).ColumnName)
'Next
cryRpt.load(strReportPath)
Dim param1Fields As New
CrystalDecisions.Shared.ParameterFields
Dim param1Field As New CrystalDecisions.Shared.ParameterField
Dim param1Range As New
CrystalDecisions.Shared.ParameterDiscreteValue
Dim param2Field As New CrystalDecisions.Shared.ParameterField
Dim param2Range As New
CrystalDecisions.Shared.ParameterDiscreteValue
param1Field.ParameterFieldName = "@t1_id"
param2Field.ParameterFieldName = "@t2_id"
param1Range.Value = "xx"
param2Range.Value = "yy"
param1Field.CurrentValues.Add(param1Range)
param2Field.CurrentValues.Add(param1Range)
param1Fields.Add(param1Field)
param1Fields.Add(param2Field)
CrystalReportViewer1.ParameterFieldInfo = param1Fields 'to
pass parameter inf.to CRV
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
Next
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class
report opens, it asks me for connection information. This is happening since
I have windows authenication on my desktop (when running the vb.net
application) but I have sql server authenication only once The crystal report
is running. Thus can you tell me how to pass in the sql server authenication
once the crystal report opens up? Here is my code right now:
Dim cryRpt As New ReportDocument
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim cryRpt As New ReportDocument
Dim sql As String
Dim connetionString As String
Dim connection As SqlConnection
Dim connetionString2 As String
Dim connection2 As SqlConnection
Dim adapter As SqlDataAdapter
Dim ds As New DataSet
'located crystal report from
Dim strReportPath As String = "C:\test.rpt"
connetionString = "Data Source=server name,1433;Initial
Catalog=databasename;User ID=id;Password=sss"
connection = New SqlConnection(connetionString)
'sql = "select * from testtable
connection.Open()
adapter = New SqlDataAdapter(sql, connection)
adapter.Fill(ds)
connection.Close()
Try
For i = 0 To ds.Tables(0).Rows.Count - 1
'for get individual columns in a table
'dt = ds.Tables(0)
'For i = 0 To dt.Columns.Count - 1
' MsgBox(dt.Columns(i).ColumnName)
'Next
cryRpt.load(strReportPath)
Dim param1Fields As New
CrystalDecisions.Shared.ParameterFields
Dim param1Field As New CrystalDecisions.Shared.ParameterField
Dim param1Range As New
CrystalDecisions.Shared.ParameterDiscreteValue
Dim param2Field As New CrystalDecisions.Shared.ParameterField
Dim param2Range As New
CrystalDecisions.Shared.ParameterDiscreteValue
param1Field.ParameterFieldName = "@t1_id"
param2Field.ParameterFieldName = "@t2_id"
param1Range.Value = "xx"
param2Range.Value = "yy"
param1Field.CurrentValues.Add(param1Range)
param2Field.CurrentValues.Add(param1Range)
param1Fields.Add(param1Field)
param1Fields.Add(param2Field)
CrystalReportViewer1.ParameterFieldInfo = param1Fields 'to
pass parameter inf.to CRV
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
Next
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class