.net
fodiaz
Messages postés
90
Date d'inscription
Statut
Membre
Dernière intervention
-
fodiaz Messages postés 90 Date d'inscription Statut Membre Dernière intervention -
fodiaz Messages postés 90 Date d'inscription Statut Membre Dernière intervention -
Bonjour,bonjour les genits svp mon code de connection a la base de donnée mysql ne marche pas il me signal l'ereur sur la partie qui me permet de remplir le dataset avec le contenu de la commande select:MyAdapter.Fill(ds);svp aidez cela des jours que je n'arrive pa avancé sur mon projet
A voir également:
- .net
- Net framework 2.0 - Télécharger - Divers Utilitaires
- Paint net - Télécharger - Dessin & Illustration
- Logo .net - Télécharger - Études & Formations
- Net framework 4.0 - Télécharger - Divers Utilitaires
- Onoffapp net - Forum Vos droits sur internet
2 réponses
toujours rien voila mon code ;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using MySql.Data.MySqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace testMysql
{
public partial class Form1 : Form
{
private MySqlConnection Connection=new MySqlConnection();
private MySqlConnection MyAdapter=new MySqlConnection();
private DataSet ds=new DataSet();
public Form1()
{
InitializeComponent();
}
private void btconnect_Click(object sender, EventArgs e)
{
string ConnectionStr = String.Empty;
if ((tbhote.Text.Length == 0) || (tbbase.Text.Length == 0) || (tblogin.Text.Length == 0))
{
MessageBox.Show("Eurreur,les champs Hote,Base et Login doivent etre remplis", "Erreur",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{//on defit la channe de connection
ConnectionStr = "Database =" + tbbase.Text + ";Data source=" + tbhote.Text + ";User Id=" + tblogin.Text + ";Password=" + tbpwd.Text;
}
Connection.ConnectionString = ConnectionStr;
try
{
//on ouvre la connexion
Connection.Open();
//on definit la requete SELECT à excuter
string MysqlCmd = "SELECT*FROM personne";
//----------------------------
//on associe cette requete a la proprieté SelectCommand du MysqlDataAdapter
MyAdapter.Fill(ds);
//on affiche le datagrid
dataGrid1.DataSource = ds.Tables[0];
dataGrid1.Refresh();
//on ferme la connexion le plus tot possible
Connection.Close();
}
catch (MySqlException Ex)
{
MessageBox.Show("Erreur SQL:\n" + Ex.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
quand je compile il me signal a ce niveau : MyAdapter.Fill(ds);
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using MySql.Data.MySqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace testMysql
{
public partial class Form1 : Form
{
private MySqlConnection Connection=new MySqlConnection();
private MySqlConnection MyAdapter=new MySqlConnection();
private DataSet ds=new DataSet();
public Form1()
{
InitializeComponent();
}
private void btconnect_Click(object sender, EventArgs e)
{
string ConnectionStr = String.Empty;
if ((tbhote.Text.Length == 0) || (tbbase.Text.Length == 0) || (tblogin.Text.Length == 0))
{
MessageBox.Show("Eurreur,les champs Hote,Base et Login doivent etre remplis", "Erreur",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{//on defit la channe de connection
ConnectionStr = "Database =" + tbbase.Text + ";Data source=" + tbhote.Text + ";User Id=" + tblogin.Text + ";Password=" + tbpwd.Text;
}
Connection.ConnectionString = ConnectionStr;
try
{
//on ouvre la connexion
Connection.Open();
//on definit la requete SELECT à excuter
string MysqlCmd = "SELECT*FROM personne";
//----------------------------
//on associe cette requete a la proprieté SelectCommand du MysqlDataAdapter
MyAdapter.Fill(ds);
//on affiche le datagrid
dataGrid1.DataSource = ds.Tables[0];
dataGrid1.Refresh();
//on ferme la connexion le plus tot possible
Connection.Close();
}
catch (MySqlException Ex)
{
MessageBox.Show("Erreur SQL:\n" + Ex.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
quand je compile il me signal a ce niveau : MyAdapter.Fill(ds);