Winform running on Parallels with SQLite - c#

Recently I moved some of my winform app data to SQLite. The app runs fine on all windows machines but Parallels on mac I am getting unable to open database file error. I can create the db file without any issues. But as soon as I check table exists I get the above error.
This file creation step works fine
SQLiteConnection.CreateFile(dbFile);
But new connection step is failing.
SQLiteConnection dbConnection = new SQLiteConnection("Data Source=mydb.db3;Version=3;");
Error Stack
System.Data.SQLite.SQLiteException: unable to open database file
at System.Data.SQLite.SQLite3.Open(String strFilename, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, Int32 maxPoolSize, Boolean usePool)
at System.Data.SQLite.SQLiteConnection.Open()
at App.clsSQLiteDB.CheckTableExists(String table)

I managed to solve the problem. Have to set the ParseViaFramework parameter true in the connection string.
SQLiteConnection dbConnection = new SQLiteConnection("Data Source=mydb.db3;Version=3;", true);

Related

SQL Server database connection string issue to run application in different machines

I have created a desktop app it is working fine in my PC with the connection string as follows:
SqlConnection conn = new SqlConnection(#"Data Source=DESKTOP-IAS4D;Initial Catalog= MConsole;Integrated Security=True");
But it is not working on another PC. So I changed the connection string so that the application can be used in any PC:
SqlConnection conn = new SqlConnection(#"Server=.\SQLExpress;AttachDbFilename=|DataDirectory|\MConsole.mdf;Trusted_Connection=Yes;Integrated Security=True;");
But I get the following error:
System.Data.SqlClient.SqlException: 'An attempt to attach an auto-named database for file C:\Users\Hp\source\repos\ MConsole\bin\Debug\Databases\MConsole.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
I want my application to work in different machines with my database. Please resolve my issue. Any kind of help will be appreciated.
Thanks in advance.

OracleConnection.Open() not working in ASP.NET

I have a VC# application that tries to open an Oracle database, but when it calls OracleConnection.Open(), it throws, "Attempted to read or write protected memory."
Here is the stack trace of the error:
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Oracle.DataAccess.Client.OpsCon.Open1(IntPtr& opsConCtx, IntPtr& opsErrCtx, OpoConValCtx* pOpoConValCtx, OpoConRefCtx& pOpoConRefCtx)
at Oracle.DataAccess.Client.OpsCon.Open(IntPtr& opsConCtx, IntPtr& opsErrCtx, OpoConValCtx* pOpoConValCtx, OpoConRefCtx& pOpoConRefCtx)
at Oracle.DataAccess.Client.ConnectionDispenser.CreateConnectionPool(OpoConCtx& opoConCtx)
at Oracle.DataAccess.Client.ConnectionDispenser.GetConnectionPool(OpoConCtx& opoConCtx, Boolean& bConObtained)
at Oracle.DataAccess.Client.ConnectionDispenser.Open(OpoConCtx opoConCtx, Int32 enlistAttrVal, Boolean& bGotEnlistedConnection)
at Oracle.DataAccess.Client.OracleConnectionOCP.Open(OracleConnection con)
at Oracle.DataAccess.Client.OracleConnection.Open()
at GenericOracleLogin.frmMain.btnLogin_Click(Object sender, EventArgs e)
in C:\VS\Workspaces\Visual Studio 2017\Projects\GenericOracleLogin\GenericOracleLogin\Form1.cs:line 56
Here is the relevant portion of the C# code:
OracleConnectionStringBuilder ConnString = new OracleConnectionStringBuilder();
ConnString.DataSource = txtDataSource.Text;
ConnString.UserID = txtUsername.Text;
ConnString.Password = txtPassword.Text;
String ConnectionString = ConnString.ToString();
Conn = new OracleConnection(ConnectionString);
Conn.Open();
The exception is thrown at Conn.Open()
I am using Oracle.DataAccess version 4.122.1.0; it is a 64-bit version running on a 64-bit app
Two things to note:
First, this is being done after Oracle was uninstalled and then reinstalled into a different directory. I can't find any references to "oracle.dataaccess" in any of the GAC directories. I also don't see any BindingRedirects in any readable machine.config files.
Second, when I use Oracle.ManagedDataAccess in place of Oracle.DataAccess, the code works.
I assume that the problem is, it is not using the specific version of Oracle.DataAccess.dll that I want it to use. How do I fix this?
I discovered that, while my main Oracle odp.net directory had Oracle.DataAccess.dll version 4.122.1.20161216, which is what I was using, my Oracle Data Toold odp.net directory had version 4.122.1.20170524. When I used the newer version, the app ran successfully.

Asp.net error on trying to connect with database

I am trying to connect to a database which is an .mdb file from my web application on asp.net. This error comes up 'Microsoft.ACE.OLEDB.12.0 Data Source =C:\Users\KIKI\Desktop\ASP.net labs\Erg8\Erg8\ebookstoredb.mdb' provider is not registered on the local machine. The thing is that on my connection string I don't use version 12 but 4. I tried installing Microsoft Access Database Engine 2010 Redistributable which gives me the option to select version 12 when I set it the connection from the "Server Explorer" window but the error is still there. Any ideas? I have spent hours looking for a solution...
Here is my connection string:
OleDbConnection constring = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\KIKI\\Desktop\\ASP.net labs\\Erg8\\Erg8\\ebookstoredb.mdb");
Also, I tested the connection when I set it and a message "Connection Succeeded" came up. The problem seems to be when I run the application on the browser.

Connecting to an mdb file using OdbcConnection in VS2013

I am trying to connect to an mdb file from C# 2013 using OdbcConnection. I used to have Office 2000 on my Windows 7 and Windows 8 machines, but I have upgraded to Office 2013 on both and it now longer works on either. My database is still in mdb format.
Here's the code:
const string myConnectionString = #"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Path\Mydb.mdb";
OdbcConnection connRL = new OdbcConnection();
connRL.Open();
Whatever I have tried I get the following error:
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not
found and no default driver specified
I have Installed the "Microsoft Access Database Engine 2010 Redistributable" and the "2007 Office System Driver: Data Connectivity Components" but neither of them have made any difference. I can create a new Data Source from the VS 2013 Project menu and that all works at design time.
When I create a blank udl file and double click on it and go to the provider tab there's nothing listed about Access or Jet, but I can see the providers in the registry at HKEY_CURRENT_USER\Software\Microsoft\VWDExpress\12.0_Config\DataProviders. Why aren't they there?
What else can I do to get this to work? I have tried everything I can think of.
I assume you can't connect to the mdb through OdbcConnection. Anyway, to connect to the DB you must specify the connection string on your connection object which is not specified in your code.
To access mdb use code like this:
const string myConnectionString = #"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Path\Mydb.mdb";
using(var connRL = new OleDbConnection(myConnectionString))
{
//use your connection
}

Listener was not given the SERVICE_NAME in CONNECT_DATA : ORA-12504

On a c# application, I'm trying to get a connexion to a distant Oracle Server.
This is my connexion chain:
OracleConnection conn = new OracleConnection("Data Source=xx.xx.xx.xx:xxxx;User Id=xxxxx;Password=xxxxxx; Integrated Security=True")
I have never performed an OracleConnection and I'm not at ease with this..
Firstly, Visual studio told me I had to install install an Oracle Client. I have now the Oracle 11g Client Release 2.
Now when I try to connect to the OracleDB, I have the error message: ORA-12504:Listener was not given the SERVICE_NAME in CONNECT_DATA
I suppose I have to add a Service Name into my OracleConnection chain like this:
OracleConnection conn = new OracleConnection("Data Source=xx.xx.xx.xx:xxxx;User Id=xxxxx;Password=xxxxxx;Integrated Security=True;Service Name=Oracle")
There I have a new error message: Keyword not handled:service name
If anybody has already performed an Oracle connection from visual studio (I'm on Ultimate 2013), a few help won't be in denial.
Old question, but thought I ran into the issue today so I thought it may help someone:
I had a similar issue and it ended up being that my Connection string was specifying the incorrect Data Source name. It has the match the entry you have in the TNSNAMES file on the server, and mine didn't.

Categories

Resources