I am trying to build a desktop application. I need to create a report but I don't know how to do? I am using to use FireBird for my Database. I am using windows 8.1.
Of course I am not forget to googling, but I do not know what is wrong with my steps.
The following are the steps that I have tried to do :
download ODBC Driver from this link and install it.
download Firebird-2.5.5.26952-0_x64_embed.zip and extract it to path C:\Firebird-2.5.5.26952-0_x64_embed
Try to Add ODBC Data Source Administrator like this image
I try to test connection but I get an error Open Database C:\Users\User\Documents\FDB\TEST.GDB failed
Whats wrong with my steps?
I am new in c#.
The field Database have to be in following format:
:
for example:
127.0.0.1:c:\Databases\data.gdb
Related
I'm using SQLiteAsyncConnection in my project to hold my data locally. I would like to see the data inside its tables like using sql server maybe or some tool like that. I've tried where it was created and to open that .db file with sql server but I didn't managed to find it's location
this is how I create the db
var path = Path.Combine(FileSystem.AppDataDirectory, "AppointmentsDB.db");
db = new SQLiteAsyncConnection(path);
I have tried printing the path or
db.DatabasePath
but it gives me a relative path something like this
/data/data/com.companyname.appointments
and I don't know that it's relative to
Now my question is.. is it possible to open that SQLite database with a "visual" tool like sql server 2019? If now then what would you suggest me to use so I can also see that data from sql server 2019?
You can execute "adb pull" to remove the database file from the emulator and put it on your regular hard drive. Similar to "adb pull /data/data/com.companyname.appointments/databases/xxx.db".
If you want to view directly, you need to root your emulator.
I'm writing a WPF application.
Trying to use the normal method of getting a connection returns an error similar to: "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine."
ACE.OLEDB has never been installed on this machine so this error makes sense.
I'm trying to create this application in a way so that our users won't need to contact IT to have the application installed. Getting IT involved is a no go situation and the project will be abandoned.
Another team has an Access database (accdb) that I want my application to extract information (only read, no insert or update). I talked to the team and they won't convert this database back to an earlier version (mdb).
After my research I assume that installing ACE.OLEDB without using Admin privileges is impossible. Because of this and my application requirement of not requiring admin privileges I need to start looking for "Mutant"/Dirty solutions that don't involve ACE.OLEDB.
I tried using power-shell but I'm getting the same problems as I had with C# (requires IT to install ACE.OLEDB).
I have two potential solutions. One write a VBA script that opens up the database and dumps a query result into a file. My C# application would call this VB script and then parse the created file.
The second option is to create a new Access process using Process.Start(fullFilePath) and somehow pass the command to execute a query and somehow pass the results back to the executing application (either via a method return or first to a file).
How would you get the data out?
Is there a way for C# to duplicate the DB file and convert it from (accdb -> mdb)?
This is the second question I ask that is very similar.
C# Connecting to Access DB with no install
The difference between the two (to prevent this is a duplicate question) is that in the previous question I was looking for ways to install ACE.OLEDB without admin privileges while here I'm just looking for any other work around.
Found a workaround. It uses Microsoft.Office.Interop.Access found in NuGet.
var accApp = new Microsoft.Office.Interop.Access.Application();
accApp.OpenCurrentDatabase(#tests.DatabasePath);
Microsoft.Office.Interop.Access.Dao.Database cdb = accApp.CurrentDb();
Microsoft.Office.Interop.Access.Dao.Recordset rst =
cdb.OpenRecordset(
"SELECT * FROM Users",
Microsoft.Office.Interop.Access.Dao.RecordsetTypeEnum.dbOpenSnapshot);
while (!rst.EOF)
{
Console.WriteLine(rst.Fields["username"].Value);
rst.MoveNext();
}
rst.Close();
accApp.CloseCurrentDatabase();
accApp.Quit();
As shown in pictures, "ProjectDB.db" is a database I built through the SQLite Compact Toolbox. The database indeed exists in that folder path. The exception as in the title is thrown as I debug the app.
UWP App. Visual Studio 2017. Windows 10.
Snapshot of Errors while running application
enter image description here
enter image description here
Connection string for connecting SQL lite Database
SQLiteConnection db =
new SQLiteConnection(#"Data Source=C:\Users\georg\source\repos\DatabasePractice\ProjectDB.db;Version=3;";
db.Open();
Sqlite on Windows a directory/path should use a double backslash like this:
C:\\Users\\georg\\source
If this does not solve your problem, attempt these troubleshooting steps:
Is the Database stored on a remote server or 'read-only' directory?
Is the parent directory a 'read-only' directory?
Try executing your code with the Source="...Practice\ProjectDB;" not "\ProjectDB.db;"
Is something else attempting to read the database? Although this should throw a 'database locked' exception which makes this one unlikely.
I was facing same issue on the shared hosting server, My C# code was able to read data from SQLIte db file. But while add / update data it was throwing Error "unable to open database"
I tried many options suggested on stackoverflow But after referring https://stackoverflow.com/a/17780808/2021073 and
https://www.sqlite.org/pragma.html#pragma_journal_mode I tried adding journal mode=Off; to the Connection string
and it worked for me
sample code
SQLiteConnection connection = new SQLiteConnection("Data Source=G:\dbfolder\sqlite3.db;Version=3;Mode=ReadWrite;journal mode=Off;", true);
I have a project in C# which is created in Visual Studio 2013. I want to create an installer using Install Shield free version. I created an installer and trying to run it on other computer but, when I run it and trying to log into program, I have problems about mysql database. Error message is:
Unhandled exception has occured in you application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately.
Cannot connect.
If I click on details button, I have a serie of errors which refers on Mysql. Example:
System.Exception: Cannot connect ---> MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts.
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at simulator.ConnConfig.getConnection()
simulator is the name of the project. ConnConfig is a class where is the connection and getConnection() is a function from ConnConfig which return connection. II tried to install on another computer .NET Framework 4.5.2, SQL Server, but also didn't worked.
In my project, I use localhost server where I have a database with 2 tables. My question is, is there any possibility to add that localhost database to installer and use it on another computer? And what redistributables requires this operation? Also, I have installed on computer .NET Framework 4.5, Sql Server 2012..but when I try do add them in InstallShield via Redistributables, but it keeps saying that Needs to be downloaded. Why?
UPDATE
I have this Class where I make the conenction. But I receive error: Additional information: Illegal characters in path. at that line:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SQLite;
namespace simulator
{
class ConnConfig
{
private static string conn = "Data Source=c:\aplicatie.db;Version=3;Password=myPassword;";
public static SQLiteConnection connect = null;
private ConnConfig()
{
}
public static SQLiteConnection getConnection()
{
SQLiteConnection connect = null;
try
{
connect = new SQLiteConnection(conn);
connect.Open();// here I receive the error
return connect;
}
catch (SQLiteException e)
{
throw new Exception("Cannot connect", e);
}
}
}
}
UPDATE 3
In that class I make the connection to database. In the other forms I just use tables and their data. For connection to program, I use a login form which uses this class to getConnection(). I created that database by adding an ADO.NET in simulator project. And with that, it comes those 2 tables that I already have in localhost server. So, Is ok if I have to create another empty database with new tables, but where to include that code or how to use it, because I don't get how that script works..where should I put it?
If your database is going to be installed on each client and your tables are not massive you might want to look at something lighter like SQLite which doesn't need any installation just the dlls and is very fast and efficient and only runs when your program does.
As for for the Needs to be Downloaded issue, it seems you have not setup your prerequisite correctly, you an correct this by following the steps in this article
Adding InstallShield Prerequisites, Merge Modules, and Objects to Basic MSI and InstallScript MSI Projects
You might want to look into determining if MySQL is the right solution for you.
SQLite vs MySQL vs PostgreSQL: A Comparison Of Relational Database Management Systems
And to see the limitations of SQLite SQLite
Because honestly seems like overkill to install MySQL on every system. If you had one server with MySQL on the network, okay. But on every system seems like a bad idea.
As far as connecting to an SQLite database here is a List of Connection Strings for SQLite
See this topic on how to create Databases and tables Create SQLite Database and table
My guess is your program doesn't bundle up the database alongside the setup upon deployment. This may be due to the fact that you didn't mark your database as a Data File in the Project Files. Try this, right click on your project name in Solution Explorer and select Properties from Menu. From the horizontal tabs click on the Publish Tab. Under Install Mode and Settings click the Application Files button. A dialog box appears with all Application files. Set your database Publish Status to Data File from the drop down on the corresponding cell. This way your database will be bundled together with the setup upon publishing. Hope this helps.
You can access SQLite via ODBC.
I created a crystal report using test a DB. I run the report using .NET ReportDocument class. Everything works fine until I connect to the test DB.
When same report is pointed to UAT DB (all required DB objects are available in UAT too), I am getting error. To fix this, I have to change the server name to UAT DB manually in the RPT file.
How to fix this?
A solution is to create a system DSN (ODBC) for connecting to your target database. You can then switch the ODBC to whichever database you want (local,test,stage etc). Also, if you ensure an ODBC connection of the same name is available on all your servers, moving the report from dev->test->stage->production should be easy.
Using push reports should solve your issue. You can set up the report to accept a strongly-typed ADO.NET Dataset, and supply that dataset at runtime.
Isn't that how it's supposed to work? It has to know to what DB it's connecting?
Maybe I'm missing something but it sounds like you just needed to get the connection right.