Connexion MySQL, problème de type.
Bonjour,
Voila je développe actuellement un programme de gestion des stocks et je doit bien evidemment executer des requetes sql, mais je rencontre un problème lors de ma connexion :
Citation:
Impossible de convertir implicitement le type 'string' en 'MySql.Data.MySqlClient.MySqlConnection'
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using MySql.Data.Types;
namespace GESTION_STOCK
{
public partial class frm_gestion_stock_acceuil : Form
{
public frm_gestion_stock_acceuil()
{
InitializeComponent();
}
private void hsb_prix_Scroll(object sender, ScrollEventArgs e)
{
this.tbx_prix_value.Text = hsb_prix.Value.ToString();
}
private void btn_search_Click(object sender, EventArgs e)
{
if (tbx_search_designation.Text == "" && tbx_search_reference.Text == "" &&
hsb_prix.Value == 0 && cbx_marque.SelectedItem == null && clb_type.CheckedItems.Count == 0)
{
MessageBox.Show("Au moins un paramètre requis.");
}
else
{
string maconnexion = "Server=localhost;Database=stock;Uid=admin;Pwd=admin";
MySqlConnection connexion = new MySqlConnection(maconnexion);
connexion.Open();
string SQL = "INSERT INTO produit VALUES ('symantec',199.34,'ie54','routeur','routeur propre',4)";
MySqlCommand execute = new MySqlCommand(SQL, connexion);
connexion.Close();
}
}
}
} |
Le problème survient à la ligne :
Code:
execute.Connection = connStr;
Auriez vous une idée sur comment le résoudre.
Merci d'avance.