ajonesprogrammer
Programmer
Everytime I run a crystal report it asks for my sql logon information. I have already tried hardcoding connection info and applying the database name and userid and password. Below is the code for the call to the report:
'Bind to crystal
Try
Dim crConnInfo As New ConnectionInfo
Dim crReportDocument As New CrystalReport1
Dim CrTables As Tables
Dim CrTable As Table
Dim crtableLogoninfos As New TableLogOnInfos
Dim crtableLogoninfo As New TableLogOnInfo
myConnection_1 = New SqlConnection("Data Source=rotary_whse;user id=sa;password=truelies;" & _
"Initial Catalog=PaintLineTemp;")
MyCommand_1.Connection = myConnection
MyCommand_1.CommandText = "SELECT * FROM tblTemp"
MyCommand_1.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand
myDA.Fill(myDS, "tblTemp")
With crConnInfo
.DatabaseName = "ROTARY_WHSE"
.UserID = "pline"
.Password = "410989"
End With
CrTables = crReportDocument.Database.Tables
'Loop through each table in the report and apply the
'LogonInfo information
For Each CrTable In CrTables
CrTableLogonInfo = CrTable.LogonInfo
crtableLogoninfo.ConnectionInfo = crConnInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
'If your DatabaseName is changing at runtime, specify
'the table location.
'For example, when you are reporting off of a
'Northwind database on SQL server you
'should have the following line of code:
'CrTable.Location = "PaintLineTemp.dbo." & CrTable.Location.Substring(CrTable.Location.LastIndexOf(".") + 1)
Next
rpt.SetDataSource(myDS)
CrystalReportViewer1.ReportSource = rpt
myConnection.Close()
myConnection_1.Close()
Catch Excep As Exception
MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
As you can see, I have utilized code straight from Crystal Reports help website and it DOES NOT work. Any help would be great.
Thanks in advance.
'Bind to crystal
Try
Dim crConnInfo As New ConnectionInfo
Dim crReportDocument As New CrystalReport1
Dim CrTables As Tables
Dim CrTable As Table
Dim crtableLogoninfos As New TableLogOnInfos
Dim crtableLogoninfo As New TableLogOnInfo
myConnection_1 = New SqlConnection("Data Source=rotary_whse;user id=sa;password=truelies;" & _
"Initial Catalog=PaintLineTemp;")
MyCommand_1.Connection = myConnection
MyCommand_1.CommandText = "SELECT * FROM tblTemp"
MyCommand_1.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand
myDA.Fill(myDS, "tblTemp")
With crConnInfo
.DatabaseName = "ROTARY_WHSE"
.UserID = "pline"
.Password = "410989"
End With
CrTables = crReportDocument.Database.Tables
'Loop through each table in the report and apply the
'LogonInfo information
For Each CrTable In CrTables
CrTableLogonInfo = CrTable.LogonInfo
crtableLogoninfo.ConnectionInfo = crConnInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
'If your DatabaseName is changing at runtime, specify
'the table location.
'For example, when you are reporting off of a
'Northwind database on SQL server you
'should have the following line of code:
'CrTable.Location = "PaintLineTemp.dbo." & CrTable.Location.Substring(CrTable.Location.LastIndexOf(".") + 1)
Next
rpt.SetDataSource(myDS)
CrystalReportViewer1.ReportSource = rpt
myConnection.Close()
myConnection_1.Close()
Catch Excep As Exception
MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
As you can see, I have utilized code straight from Crystal Reports help website and it DOES NOT work. Any help would be great.
Thanks in advance.