Connect to MySQL via OLEDB - c#

I need to connect my app to MySQL via OLEDB. I wrote this:
oleDbConnection = new OleDbConnection();
oleDbConnection.ConnectionString = "Provider=MySQLProv; Data Source=myHostName; Initial Catalog=dmz_storage; User ID=myUserName; Password=myPassword;";
oleDbConnection.Open();
But I get an exception: Provider MySQLProv is not registered at the local computer. Of course, I add MySQL.Data.dll to my project. So how can I register MySQLProv? Or can I actually connect to MySQL via OLEDB?

Related

how to connect c# windows form with remote mysql database

I want to connect my server pc MySQL database with client pcs. I make configurations in xampp server. PHPMyAdmin shares with fine in other client pcs. but I run my c# form it gets connection name error. this is my connectiondb class in c# form.
public static MySqlConnection conString()
{
MySqlConnection conn = new MySqlConnection(#"server=http://192.168.8.102; userid=root; password=0713; database=pos_system; port=3306");
return conn;
}
I try to run my application using a client pc but it shows this name cannot find. how to fix my error. I also open firewall port 3306.
Your connection string format is not correct for MySql, try something like this:
var con = new MySqlConnection(#"Server=192.168.8.102;Port=3306;Database=pos_system;Uid=root;Pwd=0713;");
For more information check:
https://www.connectionstrings.com/mysql/

Connecting to Microsoft Access file at server

I have this access.mdb at server folder. My webpage will connect to this access database using :
"Data Source=" & Server.MapPath("/cloud/login/mydatabase.mdb")
so the server path will be www.abc.com/cloud/login/mydatabase.mdb.
How can I connect to this database from my computer?
using C# or access
string connectionString = "PROVIDER=Microsoft.ACE.OLEDB.12;DATA SOURCE=www.abc.net/cloud/login/login.mdb;";
OleDbConnection con = new OleDbConnection(connectionString);
con.Open();
I tried connecting to server database using Access/ExternalData and point to the server path but I am unable to connect.
Reason why I am doing this is because when I change data, I need to use FTP to download this .mdb and change and upload back. Which is very troublesome.
Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=\\serverName\cloud\login\login.mdb;
Note: The Server name is where you have ur mdb , so put that name. The folder which u access should be shared for access.

How to Connect From WindowsApplication Sqlite Database

I have a Windows Application written in C#, using Sqlite3 as its database. I want to update my database in Host with my Windows Application database.
You can connect to an SQLite3 database using the following code.
SQLiteConnection db = new SQLiteConnection("Data Source=/path/to/file.db;Version=3;");
db.Open();
If you want to specify additional connection parameters, ConnectionStrings.com is always a good resource. Also, you might check out this question which is similar to yours.

SQL Server CE Database Connection Issues

I have an application with a database called voodoobase.sdf.
Using .NET Framework Data Provider for Microsoft SQL Server Compact 3.5
I can see it in Server Explorer and connect to it fine from there. The DB File is located in:
c:\Users\me\Documents\VisualStudio2010\Projects\testproj\voodoobase.sdf
The same named DB under Solution Explorer is said to reside at the same location.
c:\Users\me\Documents\VisualStudio2010\Projects\testproj\voodoobase.sdf
Assuming they are the same... why can my application which compiles successfully alwways crash with a connection error:
SqlConnection dbCon = new SqlConnection(Properties.Settings.Default.voodoobaseConnectionString);
dbCon.Open();
Throws an error on dbCon.Open() saying that could not get a connection to the SQL server. Let me know if further detail is required.
Do not use the SqlConnection class, but the SqlCeConnection class.

SQL connection string for database on network

I want to connect to a database on a host except localhost, my DBMS is SQL Server and I'm using ado.net, like this:
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand cmd = new SqlCommand("insert into st (ID,Name) values ('"+cnt.ToString()+"','havijuri');", con);
//some sql commands.
con.Close();
what should I use as the constr (connection string), and with these information:
host IP: 10.15.10.12
the file is database1.mdf,
in this directory(on the host): D:\Project1\DataBase
Tell me if any other information is needed
If the mdf file is not attached to an instance of sql server and you want to connect to the database while it does not exist on the same machine as your application, you need first to copy the database to the server with the mentioned IP and attach it to an instance of sql server installed on that server.
The connection string in this case -if you have a domain and will be authenticated to the database server by windows authentication- will be as follows:
"data source=10.15.10.12; integrated security=SSPI;initial catalog=database1"
Or you can create a sql server user on the database sever and connect using the following connection string:
"data source=10.15.10.12; initial catalog=database1;user id=<username>;password=<password>"
http://www.connectionstrings.com/sql-server-2008
create a file on your desktop called test.udl open it up and follow the steps to connect to your database then click test to make sure it works. then open the file in notepad, it will be 1 line and contain the connection string
and with these information:
•host IP: 10.15.10.12 •the file is
database1.mdf, •in this directory(on
the host): D:\Project1\DataBase
You can not. Database file attachment is only supported by express, not by the real server. ForSL Server, you need the database name (which can be different than the file name) and the database must e mounted first by the DBA. You also need acces to the server (as in: username, password). The security credentials are - again - determined by the DBA.
So, you miss the critical information (name of the database, username, password) to access a database server.

Categories

Resources