Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have code to connect with SQL and I know how to do it. But I have problem with mysql. For Sql I used this connection string

<configuration>
<configsections>

<connectionstrings>

<add name="Aplikacion.Properties.Settings.dbBIBLOTEKAConnectionString">
connectionString="Data Source=BESART-ARSENAL\SQLEXPRESS;Initial Catalog=dbBIBLOTEKA;Integrated Security=True"
providerName="System.Data.SqlClient" />





Then I dont know what to do in Data=> add a new data sourc in c# many.
and then the part of code e.x I have text box "name" and textt box "surname" and table in mysql with two colums NAME and SURNAME. I want to send data from my applicaton in windwos from to Mysql table.
Posted
Comments
Oshtri Deka 12-Jun-12 6:24am    
"BESART-ARSENAL\SQLEXPRESS" isn't name of a MySQL server or you have twisted sense of humor.

You should do some homework first. Read this for your reference.
Or this.

Or just Google it.
This is rather familiar topic.
 
Share this answer
 
Comments
h5h5 12-Jun-12 6:43am    
I cant find mysql.data during I am adding reference.
Data Source= ServerName; Initial Catalog=databasename; user id=yourid;password=yourpassword

user id and password is applicable if your sql server connect with Sql Server Authentication
if your sqlserver connect with windows authentication than user id and password is not require...........
Try this...
I hope it will be work
 
Share this answer
 
you need a mysql connector http://dev.mysql.com/downloads/connector/net/1.0.html[^]

donload from here then add reference in project

add this line in Proj
using MySql.Data.MySqlClient;

private void Form1_Load(object sender, EventArgs e)
{
//Set up connection string
string connString = @" server = localhost;
database = sujeetdb;
user id = root;
password =12345; ";
//Set up query string
string sql = @" select * from login ";
MySqlConnection conn=null ;
try
{
conn = new MySqlConnection(connString);
conn.Open();
MySqlCommand cmd = new MySqlCommand(sql, conn);
MySqlDataAdapter adap = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet();
adap.Fill(ds);
dataGridView1.DataSource=ds.Tables[0];
}
catch (Exception ex)
{
Console.WriteLine("Error " + ex);
}
finally
{
conn.Close();
}
}
 
Share this answer
 
v2
Comments
h5h5 12-Jun-12 8:12am    
I have two textboxes and when I put data on it when i click buton send. I want those data then to go in mysql.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900