MissingManifestResourceException through SmartDeviceProject? - c#

I am new to SmartDeviceProject. So When i try to connect MySQL to my project, MissingManifestResourceException through in Connection.open in below code?.
string connectionString = "server=192.168.1.100;database=mcubic;User Name=mcubic;Password=mcs#2011$;";
string query = "select b.Outlet_Master_Name from mcs_user_outlet a,outlet_master b where a.Mcs_User_Outlet_User_Id=3 and a.Mcs_User_Outlet_Outlet_Id = b.Outlet_Master_Id";
MySqlConnection connection = new MySqlConnection(connectionString);
MySqlCommand command = new MySqlCommand(query, connection);
connection.Open();
MySqlDataReader Reader = command.ExecuteReader();
while (Reader.Read())
{
comboBox1.Items.Add(Reader[0].ToString());
}
connection.Close();
How do i solve this,. I am imported MySql.Data.CF.dll for this project.

Via Krish Kapadia from MSDN forums:
Solution :
MySql's version 5.2.7.0 is the stable version. I use dll of this version. Other versions have many problems. so first I download dll of that version from mysql site.
here is the link :
http://dev.mysql.com/downloads/connector/net/5.2.html
I have inserted one entry in 'mysql.user' table in which hostname will be '%' (means any user can connect to mysql). If you don't want to insert entry with hostname then you have to insert for all ip addresses who should be allowed to connect to mysql.
After inserting entry in 'mysql.user', I restarted MySQL service.
And then trying to connect to mysql and Connected....
source:
http://social.msdn.microsoft.com/Forums/eu/netfxcompact/thread/66f6386a-9963-4c2f-8d39-1c507a26a6c7

Related

how to create a setup or installer file and adding MYSQL reference using visual studio C# and MYSQL for deploy my project into another system?

I'm develop a new project for Medical Laboratory by using visual studio C# WinForms for user interaction and MYSQL for database. After my successful build its running successfully in my windows machine. But the problem is when I install my project on another windows machine, the front end of UI running well but the database throw an error to me. The error is Authentication to host 'localhost' for user 'root' using method 'caching_sha2_password' failed with message: Unknown database 'login'. I think the error was I need to add MYSQL reference in my project. but I'm absolutely don't know how to do it. I'm really sorry to all coz I'm noob in C# and my English.
and literally thanks to all.
public partial class registration : Form
{
string connectionstring = "server = localhost; user id = root; database = login; password =
qwerty;";
MySqlConnection connection = new MySqlConnection(connectionstring);
MySqlCommand cmd;
connection.Open();
try
{
cmd = connection.CreateCommand();
cmd.CommandText = "ALTER TABLE register ADD UNIQUE INDEX(rgstrid);";
cmd.CommandText = "INSERT IGNORE INTO register(username, password,confirm) VALUES(#username,#password,#confirm)";
cmd.Parameters.Add("#username", MySqlDbType.VarChar).Value = rgstrusrnmtxtbx.Text;
cmd.Parameters.Add("#password", MySqlDbType.VarChar).Value = rgstrpswdtxtbx.Text;
cmd.Parameters.Add("#confirm", MySqlDbType.VarChar).Value = rgstrcnfrmtxtbx.Text;
DataTable table = new DataTable();
MySqlDataAdapter adapter = new MySqlDataAdapter();
adapter.SelectCommand = cmd;
adapter.Fill(table);
if (cmd.ExecuteNonQuery() == 1)
{
MessageBox.Show("Your Account resgistred Successfully", "information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Account saved Successfully","Success",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
catch (Exception)
{
throw;
}
finally
{
if (connection.State == ConnectionState.Open)
{
connection.Close();
}
}
}
You probably need to include a reference to a library to talk to MySql, like the MySql.Data package. Adding it as a nuget reference should ensure the required files are installed with the rest of the application files.
Your installer also needs to install some software. The database engine itself if you are running a local database, but also a .net connector for the ado.net driver.
At least this is how we do it. You might be able to avoid some components depending how you are accessing the database.
When installing the database you should specify the root password. For example by giving the rootpasswd=qwerty parameter to the MySQLInstallerConsole.exe program.
Your install script also needs to setup the database, i.e. either run sql files to create any tables and fill it with data, or copy the database files themselves, or run some program to create the tables.

Unable to connect to database using Oracle.ManagedDataAccess and Windows Native Authentication

I am having trouble connecting to an Oracle database using Oracle.ManagedDataAccess and Windows Native Authentication.
I am developing on a workstation from which I am able to connect to the same database using NTS via the PL/SQL Developer, and via C# code using non-managed Oracle.DataAccess. This leads me to I believe that there is nothing fundamentally wrong with either the database, workstation or the account. Now I am trying to evaluate if it's possible to switch to Oracle.ManagedDataAccess in our solution.
I've tried the following so far:
Created a new blank project OracleManagedAccessTest
Under references added the NuGet package Oracle.ManagedAccessTest v19.3.1 (the latest at the time of writing)
Update the <dataSource> tag in the App.config to match the entry in the tnsnames.ora (to make the C# project self-contained and not relying on external component)
Added <setting name="sqlnet.authentication_services" value="NTS"/> tag under <oracle.manageddataaccess.client><version number="*"><settings> in the App.config
I am using the following minimal code to test the connection:
try
{
using (OracleConnection conn = new OracleConnection("Data Source=EDBDEVD;User Id=/;"))
{
conn.Open();
}
}
catch (OracleException ex)
{
Console.WriteLine("Exception Message: " + ex.Message);
}
The attempt to connect fails with the following error: "ORA-01017: invalid username/password; logon denied"
This looks almost like too simple of a problem, yet I can't seem to resolve it, or find a workable solution online. Any help would be greatly appreciated.
Try this one:
string oradb = "Data Source=ORCL;User Id=hr;Password=hr;";
OracleConnection conn = new OracleConnection(oradb); // C#
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "select department_name from departments where department_id = 10"; cmd.CommandType = CommandType.Text;
OracleDataReader dr = cmd.ExecuteReader();
dr.Read();
label1.Text = dr.GetString(0);
see also: https://www.oracle.com/webfolder/technetwork/tutorials/obe/db/dotnet/GettingStartedNETVersion/GettingStartedNETVersion.htm

How to connect postgreSQL DB with ASP .NET MVC project

I have a problem with connection to database in my .NET ASP application. Maybe has something wrong with App.config or Web.config.
It was connected to MSSQL by default but I have tried connect it to PostgreSQL by npgsql nuget package and entity framework.
It don't even see Database Server for PostgreSQL when I want to create Migration in my project in Visual Studio ( Enable-Migrations; Add-Migration Initial; Update-database).
Here are github links of my code:
webconfig
App.config
I want to know how make it right and make it work proprely.
using System;
using Npgsql; // Npgsql .NET Data Provider for PostgreSQL
class Sample
{
static void Main(string[] args)
{
// Specify connection options and open an connection
NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;User Id=postgres;" +
"Password=pwd;Database=postgres;");
conn.Open();
// Define a query
NpgsqlCommand cmd = new NpgsqlCommand("select city from cities", conn);
// Execute a query
NpgsqlDataReader dr = cmd.ExecuteReader();
// Read all rows and output the first column in each row
while (dr.Read())
Console.Write("{0}\n", dr[0]);
// Close connection
conn.Close();
}
}

Query PostgreSQL db in C# in database agnostic way (ie without Npgsql)

Is there a way to query a PostgreSQL db in C# in a database agnostic way ie without Npgsql. I want use built in .NET libraries and a connection-string that contains the DB IP, Username, Password and any other info that the connection-string might require.
You can use ODBC and construct the connection within your app. The Postgres driver has to be installed on the machine running the program. Your app would then only be using the generic ODBC classes. Below is a simple example.
using System.Data.Odbc;
string connectString = "Driver={PostgreSQL UNICODE};Port=5432;Server=localhost;Database=myDBname;Uid=myusername;Pwd=mypassword;";
OdbcConnection connection = new OdbcConnection(connectString);
connection.Open();
string sql = "select version()";
OdbcCommand cmd = new OdbcCommand(sql, connection);
OdbcDataReader dr = cmd.ExecuteReader();
dr.Read();
string dbVersion = dr.GetString(0);

How do I connect to MySql from Genymotion

I installed mysql on machine.
I installed GenyMotion Android Emulator
I use the Xamarin MySQL Connector in my Xamarin App.
How do I connect to the mysql database from the Xamarin App running in Genymotion?
Note using 127.0.0.1 as an IP address WON'T work for obvious reasons.
Your app shouldn't talk directly to the database server. Going through an API is a better approach.
Now that we got this out of the way here's a short example taken from here:
try
{
string connectionString = "Server=your.ip.address;Port=3306;database=YOUR_DATA_BASE;User Id=root;Password=password;charset=utf8";
MySqlConnection sqlconn = new MySqlConnection(connectionString);
sqlconn.Open();
string queryString = "select count(0) from ACCOUNT";
MySqlCommand sqlcmd = new MySqlCommand(queryString, sqlconn);
String result = sqlcmd.ExecuteScalar().ToString();
// do something with the results
sqlconn.Close();
} catch (Exception ex)
{
Console.WriteLine (ex.Message);
}
You should be able to get the IP address to use from the virtual network adapter created by GenyMotion (which uses VirtualBox)

Categories

Resources