Hassan_Ghanem
asked on
CrystalDecisions.CrystalReports.Engine.LogOnException logon failed
Hi every body..
I have created a report using ADO.NET XML (xml schema file) and in the webform I used the following procedure to log onto SQL Server database:
Private Sub LogonToReport _
(ByRef Report As ReportDocument)
Dim logonInfo As New TableLogOnInfo
Dim table As Table
' Set the logon information for each table.
For Each table In Report.Database.Tables
logonInfo = table.LogOnInfo
logonInfo.ConnectionInfo.S erverName = "xx"
logonInfo.ConnectionInfo.D atabaseNam e = "xx"
logonInfo.ConnectionInfo.U serID = "sa"
logonInfo.ConnectionInfo.P assword = "xx"
' Apply the connection information to the table.
table.ApplyLogOnInfo(logon Info)
Next table
End Sub
but I got the error "CrystalDecisions.CrystalR eports.Eng ine.LogOnE xception logon failed"
Could any body help me PLZ.. Thanks in advance...
I have created a report using ADO.NET XML (xml schema file) and in the webform I used the following procedure to log onto SQL Server database:
Private Sub LogonToReport _
(ByRef Report As ReportDocument)
Dim logonInfo As New TableLogOnInfo
Dim table As Table
' Set the logon information for each table.
For Each table In Report.Database.Tables
logonInfo = table.LogOnInfo
logonInfo.ConnectionInfo.S
logonInfo.ConnectionInfo.D
logonInfo.ConnectionInfo.U
logonInfo.ConnectionInfo.P
' Apply the connection information to the table.
table.ApplyLogOnInfo(logon
Next table
End Sub
but I got the error "CrystalDecisions.CrystalR
Could any body help me PLZ.. Thanks in advance...
The link posted by mlmcc is probably the solution you need. If not, please post the rest of the code you use to call the report.
frodoman
frodoman
ASKER
I didn't include the table name when I filled the dataSet
MyDataAdapter.Fill(dataSet )
but my SQL statement which I used to fill my dataSet contains more than one table..how could I include them...
MyDataAdapter.Fill(dataSet
but my SQL statement which I used to fill my dataSet contains more than one table..how could I include them...
I believe you just need to reference the primary table when you fill your dataset.
MyDA.Fill(dataSet, "PrimaryTable")
That should be sufficient to meet Crystal's dereferencing needs.
frodoman
MyDA.Fill(dataSet, "PrimaryTable")
That should be sufficient to meet Crystal's dereferencing needs.
frodoman
This is how I do it. Hoepfully it helps
Regards
Emre
public DataSet FillDataSet(DataSet MyDataSet)
{
SqlConnection MyConnectionString = new SqlConnection("server=xx;d atabase=xx ;UID=xx;PW D=xx;");
string SQL;
SQL = "tablename";
//Create a DataAdapter, and then provide the name of the stored procedure.
SqlDataAdapter MyDataAdapter = new SqlDataAdapter(SQL, MyConnectionString);
//Set the command type as StoredProcedure.
MyDataAdapter.SelectComman d.CommandT ype = CommandType.StoredProcedur e;
//Create and add a parameter to Parameters collection for the stored procedure.
MyDataAdapter.SelectComman d.Paramete rs.Add(new SqlParameter("@CaseID", SqlDbType.VarChar, 25));
MyDataAdapter.SelectComman d.Paramete rs.Add(new SqlParameter("@line_number ", SqlDbType.Int));
MyDataAdapter.SelectComman d.Paramete rs.Add(new SqlParameter("@company_id" , SqlDbType.VarChar, 4));
//Assign the search value to the parameter.
MyDataAdapter.SelectComman d.Paramete rs["@CaseI D"].Value = _parametervalues[0];
MyDataAdapter.SelectComman d.Paramete rs["@line_ number"].V alue = _parametervalues[1];
MyDataAdapter.SelectComman d.Paramete rs["@compa ny_id"].Va lue = _parametervalues[2];
MyDataAdapter.Fill(MyDataS et.Tables[ "tablename "]);
return MyDataSet;
}
Regards
Emre
Regards
Emre
public DataSet FillDataSet(DataSet MyDataSet)
{
SqlConnection MyConnectionString = new SqlConnection("server=xx;d
string SQL;
SQL = "tablename";
//Create a DataAdapter, and then provide the name of the stored procedure.
SqlDataAdapter MyDataAdapter = new SqlDataAdapter(SQL, MyConnectionString);
//Set the command type as StoredProcedure.
MyDataAdapter.SelectComman
//Create and add a parameter to Parameters collection for the stored procedure.
MyDataAdapter.SelectComman
MyDataAdapter.SelectComman
MyDataAdapter.SelectComman
//Assign the search value to the parameter.
MyDataAdapter.SelectComman
MyDataAdapter.SelectComman
MyDataAdapter.SelectComman
MyDataAdapter.Fill(MyDataS
return MyDataSet;
}
Regards
Emre
ASKER
frodoman what did u mean by Primay table? I have tried every table but it hasn't solve the problem..
did u try my code, If yes, you have to set all the tables connection information and parameter information. Dataset needs these information to fill it with data. The above code is written for only one table. But you can pass the table name and adjust the indexes of the parameter and load all the tables.
ASKER
ebolek.. I have done that but the problem hasn't been solved.
Can you post your code for us to look at?
what error message does it give. I know that my code works because i set it for my reports. But i have one stored proc in my dataset. why dont you do different datasets for each table. Then it will definitely work or adjust the code above to set miltiple tables from it
Regards
Emre
Regards
Emre
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
M0m0nga ... I couldn't locate setDataBaseLogon method...
the following is my code.. by the way it works on my computer even without the logon procedure but the logon error appears when I install my application on the production environment..
Dim connectionString As String = "server='xxx'; user id='xx'; password='xx'; database='xxxxx'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlC onnection( connection String)
Dim queryString As String = "SELECT Expenses.ReceiptNo, Expenses.ReceiptDate, Expenses.CheckNO, ExpensesDetails.beneficiar yName, ExpensesDetails.ItemAmount , ExpensesDetails.Descriptio n, " & _
"AccountCode.Description AS mAcct, AccountCode_1.Description AS subAcct " & _
"FROM ExpensesDetails ExpensesDetails INNER JOIN " & _
"AccountCode AccountCode_1 ON ExpensesDetails.CodeID = AccountCode_1.ID INNER JOIN " & _
"Expenses Expenses ON ExpensesDetails.ExpenseID = Expenses.ID INNER JOIN " & _
"AccountCode AccountCode ON AccountCode_1.MajorID = AccountCode.ID "
Dim dbCommand As System.Data.SqlClient.SqlC ommand = New System.Data.SqlClient.SqlC ommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dataAdapter As System.Data.SqlClient.SqlD ataAdapter = New System.Data.SqlClient.SqlD ataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
the following is my code.. by the way it works on my computer even without the logon procedure but the logon error appears when I install my application on the production environment..
Dim connectionString As String = "server='xxx'; user id='xx'; password='xx'; database='xxxxx'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlC
Dim queryString As String = "SELECT Expenses.ReceiptNo, Expenses.ReceiptDate, Expenses.CheckNO, ExpensesDetails.beneficiar
"AccountCode.Description AS mAcct, AccountCode_1.Description AS subAcct " & _
"FROM ExpensesDetails ExpensesDetails INNER JOIN " & _
"AccountCode AccountCode_1 ON ExpensesDetails.CodeID = AccountCode_1.ID INNER JOIN " & _
"Expenses Expenses ON ExpensesDetails.ExpenseID = Expenses.ID INNER JOIN " & _
"AccountCode AccountCode ON AccountCode_1.MajorID = AccountCode.ID "
Dim dbCommand As System.Data.SqlClient.SqlC
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dataAdapter As System.Data.SqlClient.SqlD
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
ASKER
Thanks M0m0nga.. Thanks all...
I have downloaded Crystal Reports .Net 1.1 Service Pack 2 and used setdatabaselogon method..
it solved my problem...
Hassan Ghanem....
I have downloaded Crystal Reports .Net 1.1 Service Pack 2 and used setdatabaselogon method..
it solved my problem...
Hassan Ghanem....
http://support.businessobjects.com/library/kbase/articles/c2011068.asp
mlmcc