I have build an Report application using C# and Crystal Report
I build program with Formula Selection to Change Query when User need to Filter the report.
The program build in Windows 7.
In the windows 7 program is running well as I needed, data and anything is shown like I needed.
But I need to run in Windows XP.
I try to filter date into to day.
The problem is on CrystalReportViewer RefreshReport();
If I don't use that function data on report doesn't refresh, but if I use that function The connection failed to logon
Here is the code:
skr = DateTime.Now.ToString("yyyy/MM/dd");
dp = new DailyParking();
dp.SetDatabaseLogon("user", "passwd", "host", "dbname");
repotviewer.ReportSource = dp;
repotviewer.SelectionFormula = "Date({transaksi1.masuk})=Date('" +skr+ "') ";
repotviewer.RefreshReport();
repotviewer.Refresh();
The answer is, Install the Another MySql Connector which compatible in XP, after that create the connection in MyODBC.
Change The code like here:
skr = DateTime.Now.ToString("yyyy/MM/dd");
dp = new DailyParking();
dp.SetDatabaseLogon("user", "passwd", "host", "dbname");
dp.RecordSelectionFormula = "Date({transaksi1.masuk}) = Date('" + skr + "') ";
repotviewer.ReportSource = dp;
repotviewer.Refresh();
Change the MySQL.Data reference with new MySQL connector same with installed in XP and Rebuil Program.
Related
I'm developing a small application that will simplify logging, it does so by adding some inputs to an MS Access database through OleDB.
let private conn = new OleDbConnection(connectionString)
let private submitCmd date wins =
let cmd = new OleDbCommand("INSERT INTO ArenaStats ([Date], [Wins]) VALUES (#Date, #Wins)",
Connection = conn, CommandType = CommandType.Text)
["#Date", box date; "#Wins", box wins]
|> List.iter (cmd.Parameters.AddWithValue >> ignore)
cmd
let private submit date wins =
try
conn.Open()
(submitCmd date wins).ExecuteNonQuery() |> ignore
finally
conn.Close()
[<CompiledName "AddEntry">]
let addEntry(date:DateTime, wins:int) =
submit date wins
Now testing this through FSI works just as expected. However, when I consume this API from a C# WPF project it will throw an SEHException at conn.Open(). I am really scratching my head over why this is happening.
Edit
As suggested, I have also tried to implement the same code purely in C# and in the same project, it will throw the same exception at the same place but I am posting the code below for reference.
class MsAccessDatabase : IArenaWinsDatabase {
private OleDbConnection connection = new OleDbConnection(connectionString);
private OleDbCommand SubmitCommand(DateTime date, int wins) {
return new OleDbCommand("INSERT INTO ArenaStats ([Date], [Wins]) VALUES (#Date, #Wins)") {
Connection = connection,
CommandType = System.Data.CommandType.Text,
Parameters = {
new OleDbParameter("#Date", date),
new OleDbParameter("#Wins", wins)
}
};
}
public void Submit(DateTime date, int wins) {
try {
connection.Open();
SubmitCommand(date, wins).ExecuteNonQuery();
}
finally {
connection.Close();
}
}
}
With some help from Philip I was able to figure it out. It seems that by default FSI is configured to run in 64-bit by default while the WPF project is set to "prefer 32-bit". Changing the target platform for the WPF project to 64-bit resolved the issue.
When trying to run the following code:
var connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}; Extended Properties=Excel 12.0;", FilePath);
OleDbConnection OleDbConnection = new System.Data.OleDb.OleDbConnection(connectionString);
OleDbConnection.Open();
An SEHException exception is thrown at runtime, with the error message 'External Component has thrown an Exception'
This will usually occur when the build configuration platform in Visual Studio is incorrect, this can occur in both build configuration platforms, x86 and x64.
This is due to a mismatch between the build configuration platform of your project and the Microsoft Access Database Engine which is installed on your machine.
In order to resolve this error:
Change the build configuration platform in Visual Studio - make sure it matches the Microsoft Access Database Engine version on your machine
Recompile and run your project
The run time error should now be resolved
I know this is a really old thread, but I just ran into the same problem with a different solution.
When I installed the Access Database Engine 2016 Redistributable (x64) for the ACE provider the installer gave me an error that VCRUNTIME140.DLL wasn't installed, but the installer completed anyways and the ACE provider was available.
Uninstalling the Access Database Engine, installing the VC++ 2015 Redistributable R3 (https://www.microsoft.com/en-us/download/confirmation.aspx?id=52685), then re-installing the Access Database Engine solved the problem.
i already went through the following questions.please don't mark as duplicate to my question. https://stackoverflow.com/questions/24432683/crystal-report-is-not-showing-data-after-some-time-in-cr-version-13-0-2000-0
I am facing this issue since last 1 month.My crystal report are working fine development environment (windows-7 32bit,VS2010,Crystal report V.13). I deployed on server (windows server-2012 64bit,core i5 ). Problem is that after some time report getting blank.I search a lot about that and use Dispose(),Close() method,right now I m using the following code.
public static void OpenPdfInBrowser(ReportClass RptReport)
{
string strFilename;
string strFolderName;
string strFile = String.Empty;
string strReportOutputName = String.Empty;
HttpResponse objResponse = HttpContext.Current.Response;
HttpSessionState objSession = HttpContext.Current.Session;
HttpServerUtility objServer = HttpContext.Current.Server;
strFolderName = objServer.MapPath("../ReportOutput");
if (Directory.Exists(strFolderName) == false)
{
Directory.CreateDirectory(strFolderName);
}
//Generate the File Name
strFilename = "";
strFile = objSession.SessionID.ToString() + "_" + DateTime.Now.Ticks.ToString() + ".pdf";
strFilename = strFolderName + "\\" + strFile;
//Set the File Name
DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
diskOpts.DiskFileName = strFilename;
//Set the Various Options
ExportOptions exportOpts = new ExportOptions();
exportOpts = RptReport.ExportOptions;
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;
exportOpts.DestinationOptions = diskOpts;
//Export the Report
RptReport.Export();
//Stream it to the Client
objResponse.ClearContent();
objResponse.ClearHeaders();
strReportOutputName = "Report";
objResponse.ContentType = "application/pdf";
objResponse.AddHeader("Content-Disposition", "inline;filename=Report.pdf");
objResponse.WriteFile(strFilename);
objResponse.Flush();
objResponse.Close();
//Delete the File
System.IO.File.Delete(strFilename);
//Close the Report Object
RptReport.Close();
RptReport.Dispose();
GC.Collect();
}
I am getting the following error in event viewer on deployment server.
The description for Event ID 4353 from source Crystal Reports cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
The keycode assembly, BusinessObjects.Licensing.KeycodeDecoder.dll, cannot be loaded.
Any help will be greatly appreciated. thanks in adnvace.
Copy your asp.net folder to server virtual directory...
Not sure but hope ur problem will resolve. Best Luck.
The issues is looking like, related to the Crystal report installation on the server... If its working fine on the Development Machine and if All the applications required to run the crystal reports are installed on the Deployment server, then please, check.. Application Pool in IIS --> select the Application Pool used for the Web applicaiton --> Advanced Settings-> Enable 32-Applications --> Set this to "True" ..
Please, try and check...
After a long research my problem has been resolved by doing following changes in registry.Actually this issue is related to Print Job Limit which by default 75 I just extend its data size according to my requirement and it work for me.
Go to-->RUN----->Regedit
1-HKEY_LOCAL_MACHINE
2-SOFTWARE
3-SAP BUSINESS OBJECT
4-CRYSTAL REPORT FOR .NET FRAMEWORK(your version no.)
5-REPORT APPLICATION SERVER
6-SERVER
then got to "PrintJobLimit" PROPERTY and change its Data size to whatever you want.
thanks for every one who help me in this
Your approach is correct to use .close and . dispose but the best way to use it is :
Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
cryRpt.Close()
cryRpt.Dispose()
End Sub
to open crystal report in PDF you can use http response it will be better in performance :
cryRpt = New ReportDocument
cryRpt.Load(Server.MapPath("Your report path"))
cryRpt.SetDataSource(Your data source)
cryRpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, True, "ExportedReport")
I am trying to set a given RDL report to use an embedded data source using my client application. I am using the ReportingService2005 class to interact with SSRS. I need to set the embedded data source to use "Credentials stored securely in the report server" and specify the username and password.
Thank you!
I solved the issue by first publishing the RDL, then calling into the ReportingService2005 GetItemDataSources() method. I then modified that datasource and subsequently called SetItemDataSources() to save the changes into SSRS. Below is a snippet of the code I accomplished this with:
var reportItem = report.TargetFolder + "/" + report.Name;
var dataSources = new DataSource[0];
dataSources = rs.GetItemDataSources(reportItem);
if (dataSources.Any())
{
var dataSource = (DataSourceDefinition)dataSources.First().Item;
dataSource.CredentialRetrieval = CredentialRetrievalEnum.Store;
dataSource.UserName = SsrsUsername;
dataSource.Password = SsrsPassword;
rs.SetItemDataSources(reportItem, dataSources);
}
I have a project that is used by several clients but for one of them using sql server 2005 wherever any code that runs a sql statement which includes a date like so:
" AND ABS.AbsenceDate = '" + DateTime.Now.ToString("yyyy-MM-dd") + "'";
I get the error: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value
This only happens for this one client/server, if I copy the actual sql string created and execute it in Sql Server on this server it runs ok. I created a test page to ensure the date string was correct and did indeed display as 2013-11-26 as expected. My assumption was that the app was sending the date as 2013-26-11 as this would cause the issue but then the test showed otherwise so leaves me stumped.
For info, this is on an English server so the regional setting is day/month/year and dates stored as year-month-day etc
Don't concatenate strings to build your sql string but sql-parameters. The main reason is to prevent sql-injection but it can also prevent localization- or conversion issues like this.
string sql = #"SELECT Columns
FROM dbo.tableName
WHERE ...
AND ABS.AbsenceDate = #AbsenceDate";
using(var con = new SqlConnection("ConnectionString"))
using(var cmd = new SqlCommand(sql, con))
{
cmd.Parameters.AddWithValue("#AbsenceDate", DateTime.Today);
con.Open();
using(var reader = cmd.ExecuteReader())
{
while(reader.Read())
{
// ...
}
}
}
I have solved the issue and quite surprised at what the problem was. I was able to run the sql ok in management studio but I was logged in using Windows Authentication. I realised I should try with the account the app uses and when logged in as this I did get the error.
Turns out whoever set the account up had the Language set to British English. I changed it to English and voila problem solved.
Never mind the added security, Sql Parameters would solve your problem automatically.
Is there a date part for that date or is it irrelevant ?
An example solution would be the following:
" AND ABS.AbsenceDate = Convert(DateTime, '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "', 20) "'
I'm using the following code to back up a SQL Database :
void BackupDatabase(string sConnect, string dbName, string backUpPath)
{
using (SqlConnection cnn = new SqlConnection(sConnect))
{
cnn.Open();
dbName = cnn.Database.ToString();
ServerConnection sc = new ServerConnection(cnn);
Server sv = new Server(sc);
// Create backup device item for the backup
BackupDeviceItem bdi = new BackupDeviceItem(backUpPath, DeviceType.File);
// Create the backup informaton
Microsoft.SqlServer.Management.Smo.Backup bk = new Backup();
bk.PercentComplete += new PercentCompleteEventHandler(percentComplete);
bk.Devices.Add(bdi);
bk.Action = BackupActionType.Database;
bk.PercentCompleteNotification = 1;
bk.BackupSetDescription = dbName;
bk.BackupSetName = dbName;
bk.Database = dbName;
//bk.ExpirationDate = DateTime.Now.AddDays(30);
bk.LogTruncation = BackupTruncateLogType.Truncate;
bk.FormatMedia = false;
bk.Initialize = true;
bk.Checksum = true;
bk.ContinueAfterError = true;
bk.Incremental = false;
// Run the backup
bk.SqlBackup(sv);
}
}
In my system (Win7 x64) it works fine but in destination system (WinXP SP3 x86) I receive the below error :
How can I fix it ?
Thanks.
If you check out the assembly directory on the Win7 machine (GAC) you'll see an entry called Microsoft.SqlServer.ConnectionInfo. (Browse to %windir%\assembly) On my machine it looks like this:
In my case I'm using version 10.0.0.0. In your case, you will at least see version 9.0.242.0 as that is what your program is compiled against (I find it unlikely that you're not referencing the dll from the GAC). If you don't have the same version installed on both machines, you've spotted the problem and you need to update the client library accordingly. I think it's likely that you have a newer version running on the XP machine, since you just installed 2008 there.
If you need more help after checking this out, you can comment here.
The sql server dll's for 32bit and 64bit are different.
It looks like your project is referencing the 64 bit dll's. When you try and run it on a machine with only 32bit dll's available you get a "file not found" / "could not load dll" type error.
If you want this to work on a 32 bit machine you should reference the 32bit version of sql server dll's.