Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

Sujet : 'System.Data.SqlClient.SqlException' s'est produite dans system.data.dll ????? [ Archives / Base de données ] (lsprax83)

jeudi 24 novembre 2005 à 22:51:32 | 'System.Data.SqlClient.SqlException' s'est produite dans system.data.dll ?????

lsprax83

bonjour tout le monde,
jai mis le code suivant :

private void Form1_Load(object sender, System.EventArgs e)

{

SqlConnection cn=new SqlConnection();

cn.ConnectionString=sqlConnection1.ConnectionString; //sqlConnection1 à été generé par l'assistant du sqlDataAdapter

SqlCommand insrt=new SqlCommand("INSERT INTO(login,password) user VALUES('foad','453788')",cn);

sqlDataAdapter1.InsertCommand=insrt;

cn.Open();

sqlDataAdapter1.InsertCommand.ExecuteNonQuery(); // c au niveau de cette ligne que l'exception s'est levée

cn.Close();

}

pour inserer une nouvelle ligne dans la table "user" dans une base de donneé sql srver, mais il me donne l'exception suivante :" Une exception non gérée du type 'System.Data.SqlClient.SqlException' s'est produite dans system.data.dll

Informations supplémentaires : Erreur système.
 "
NB:j'ai utiliser l'assistant de l'objet sqlDataAdapter qui m'a generer la connection,les commande sql et la dataset.

je me suis bloqué et je ne sais pas koi faire.
j'attens vos suggestions , aide koi ke se soit...
merci. 


vendredi 25 novembre 2005 à 10:29:25 | Re : 'System.Data.SqlClient.SqlException' s'est produite dans system.data.dll ?????

sebmafate

Membre Club Administrateur CodeS-SourceS
si je peux me permettre... quel est l'intérêt de recréer une connexion sachant qu'une autre existe déjà ?

Voici comment je recoderais :

private void Form1_Load(object sender, System.EventArgs e)

   SqlCommand insrt=new SqlCommand("INSERT INTO user (login,password)  VALUES('foad','453788')", sqlConnection1); 
   cn.Open();
   insrt.ExecuteNonQuery(); // c au niveau de cette ligne que l'exception s'est levée
   cn.Close();
}

ta requête était fausse aussi.

Sébastien FERRAND 
[MVP C#]


vendredi 25 novembre 2005 à 15:09:01 | Re : 'System.Data.SqlClient.SqlException' s'est produite dans system.data.dll ?????

lsprax83

il me donne la même exception, aprés la réctification !!!!
voici le message de l'exception :
" Une exception non gérée du type 'System.Data.SqlClient.SqlException' s'est produite dans system.data.dll

Informations supplémentaires : Erreur système."
toujour le compilateur arrete dans cette ligne : insrt.ExecuteNonQuery(); 

 


vendredi 25 novembre 2005 à 15:21:52 | Re : 'System.Data.SqlClient.SqlException' s'est produite dans system.data.dll ?????

sebmafate

Membre Club Administrateur CodeS-SourceS
tu peux remettre tout bout de code corriger ?

Sébastien FERRAND 
[MVP C#]

vendredi 25 novembre 2005 à 20:10:31 | Re : 'System.Data.SqlClient.SqlException' s'est produite dans system.data.dll ?????

lsprax83

voila tout le code :

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

using System.Data.SqlClient;

namespace tp1

{

/// <summary>

/// Description résumée de Form1.

/// </summary>

public class Form1 : System.Windows.Forms.Form

{

private System.Windows.Forms.TextBox textBox1;

private System.Windows.Forms.TextBox textBox2;

private System.Windows.Forms.Button button1;

private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;

private System.Data.SqlClient.SqlCommand sqlSelectCommand1;

private System.Data.SqlClient.SqlCommand sqlInsertCommand1;

private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;

private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;

public System.Data.SqlClient.SqlConnection sqlConnection1;

private tp1.DataSet1 dataSet11;

private System.Windows.Forms.DataGrid dataGrid1;

/// <summary>

/// Variable nécessaire au concepteur.

/// </summary>

private System.ComponentModel.Container components = null;

public Form1()

{

//

// Requis pour la prise en charge du Concepteur Windows Forms

//

InitializeComponent();

//

// TODO : ajoutez le code du constructeur après l'appel à InitializeComponent

//

}

/// <summary>

/// Nettoyage des ressources utilisées.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Code généré par le Concepteur Windows Form

/// <summary>

/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas

/// le contenu de cette méthode avec l'éditeur de code.

/// </summary>

private void InitializeComponent()

{

this.textBox1 = new System.Windows.Forms.TextBox();

this.textBox2 = new System.Windows.Forms.TextBox();

this.button1 = new System.Windows.Forms.Button();

this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();

this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();

this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();

this.dataSet11 = new tp1.DataSet1();

this.dataGrid1 = new System.Windows.Forms.DataGrid();

((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();

this.SuspendLayout();

//

// textBox1

//

this.textBox1.Location = new System.Drawing.Point(104, 32);

this.textBox1.Name = "textBox1";

this.textBox1.TabIndex = 0;

this.textBox1.Text = "";

//

// textBox2

//

this.textBox2.Location = new System.Drawing.Point(104, 64);

this.textBox2.Name = "textBox2";

this.textBox2.TabIndex = 1;

this.textBox2.Text = "";

//

// button1

//

this.button1.Location = new System.Drawing.Point(168, 96);

this.button1.Name = "button1";

this.button1.Size = new System.Drawing.Size(32, 24);

this.button1.TabIndex = 2;

this.button1.Text = "ok";

//

// sqlDataAdapter1

//

this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;

this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;

this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;

this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {

new System.Data.Common.DataTableMapping("Table", "user", new System.Data.Common.DataColumnMapping[] {

new System.Data.Common.DataColumnMapping("login", "login"),

new System.Data.Common.DataColumnMapping("password", "password")})});

this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;

//

// sqlDeleteCommand1

//

this.sqlDeleteCommand1.CommandText = "DELETE FROM [user] WHERE (login = @Original_login) AND (password = @Original_pass" +

"word OR @Original_password IS NULL AND password IS NULL)";

this.sqlDeleteCommand1.Connection = this.sqlConnection1;

this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_login", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "login", System.Data.DataRowVersion.Original, null));

this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_password", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "password", System.Data.DataRowVersion.Original, null));

//

// sqlConnection1

//

this.sqlConnection1.ConnectionString = "workstation id=LACHGAR;packet size=4096;integrated security=SSPI;data source=lach" +

"gar;persist security info=False;initial catalog=test";

//

// sqlInsertCommand1

//

this.sqlInsertCommand1.CommandText = "INSERT INTO [user] (login, password) VALUES (@login, @password); SELECT login, pa" +

"ssword FROM [user] WHERE (login = @login)";

this.sqlInsertCommand1.Connection = this.sqlConnection1;

this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@login", System.Data.SqlDbType.VarChar, 10, "login"));

this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@password", System.Data.SqlDbType.VarChar, 10, "password"));

//

// sqlSelectCommand1

//

this.sqlSelectCommand1.CommandText = "SELECT login, password FROM [user]";

this.sqlSelectCommand1.Connection = this.sqlConnection1;

//

// sqlUpdateCommand1

//

this.sqlUpdateCommand1.CommandText = "UPDATE [user] SET login = @login, password = @password WHERE (login = @Original_l" +

"ogin) AND (password = @Original_password OR @Original_password IS NULL AND passw" +

"ord IS NULL); SELECT login, password FROM [user] WHERE (login = @login)";

this.sqlUpdateCommand1.Connection = this.sqlConnection1;

this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@login", System.Data.SqlDbType.VarChar, 10, "login"));

this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@password", System.Data.SqlDbType.VarChar, 10, "password"));

this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_login", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "login", System.Data.DataRowVersion.Original, null));

this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_password", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "password", System.Data.DataRowVersion.Original, null));

//

// dataSet11

//

this.dataSet11.DataSetName = "DataSet1";

this.dataSet11.Locale = new System.Globalization.CultureInfo("fr-FR");

//

// dataGrid1

//

this.dataGrid1.AlternatingBackColor = System.Drawing.Color.Lavender;

this.dataGrid1.BackColor = System.Drawing.Color.WhiteSmoke;

this.dataGrid1.BackgroundColor = System.Drawing.Color.LightGray;

this.dataGrid1.BorderStyle = System.Windows.Forms.BorderStyle.None;

this.dataGrid1.CaptionBackColor = System.Drawing.Color.LightSteelBlue;

this.dataGrid1.CaptionFont = new System.Drawing.Font("Microsoft Sans Serif", 8F);

this.dataGrid1.CaptionForeColor = System.Drawing.Color.MidnightBlue;

this.dataGrid1.DataMember = "user";

this.dataGrid1.DataSource = this.dataSet11;

this.dataGrid1.FlatMode = true;

this.dataGrid1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F);

this.dataGrid1.ForeColor = System.Drawing.Color.MidnightBlue;

this.dataGrid1.GridLineColor = System.Drawing.Color.Gainsboro;

this.dataGrid1.GridLineStyle = System.Windows.Forms.DataGridLineStyle.None;

this.dataGrid1.HeaderBackColor = System.Drawing.Color.MidnightBlue;

this.dataGrid1.HeaderFont = new System.Drawing.Font("Microsoft Sans Serif", 8F);

this.dataGrid1.HeaderForeColor = System.Drawing.Color.WhiteSmoke;

this.dataGrid1.LinkColor = System.Drawing.Color.Teal;

this.dataGrid1.Location = new System.Drawing.Point(152, 152);

this.dataGrid1.Name = "dataGrid1";

this.dataGrid1.ParentRowsBackColor = System.Drawing.Color.Gainsboro;

this.dataGrid1.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;

this.dataGrid1.SelectionBackColor = System.Drawing.Color.CadetBlue;

this.dataGrid1.SelectionForeColor = System.Drawing.Color.WhiteSmoke;

this.dataGrid1.Size = new System.Drawing.Size(208, 96);

this.dataGrid1.TabIndex = 3;

//

// Form1

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(384, 285);

this.Controls.Add(this.dataGrid1);

this.Controls.Add(this.button1);

this.Controls.Add(this.textBox2);

this.Controls.Add(this.textBox1);

this.Name = "Form1";

this.Text = "Form1";

this.Load += new System.EventHandler(this.Form1_Load);

((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();

this.ResumeLayout(false);

}

#endregion

/// <summary>

/// Point d'entrée principal de l'application.

/// </summary>

[STAThread]

static void Main()

{

Application.Run(new Form1());

}

private void Form1_Load(object sender, System.EventArgs e)

{

sqlInsertCommand1=new SqlCommand("INSERT INTO user(login,password) VALUES('foad','453788')",sqlConnection1);

sqlConnection1.Open();

sqlInsertCommand1.ExecuteNonQuery();

sqlConnection1.Close();

}

}

}


mardi 28 octobre 2008 à 14:51:13 | Re : 'System.Data.SqlClient.SqlException' s'est produite dans system.data.dll ?????

torreshubert

j'ai eu le meme probleme puis lorque j'ai changé le nom de la classe user en utilisateur et bien c'est passé essaie et tu verras



Cette discussion est classé dans : system, data, sqlexception, cn, sqlclient


Répondre à ce message

Sujets en rapport avec ce message

comment obtenir un Dataset a partir de Web Service [ par creanova2000 ] Bonjour ,Je desir me connecter un WebService et faire des requettes sur la base de donnees SQL Server, mais cela ne se fait pas. J'ai pas d'erreur .J' System.Data.SqlClient n'existe pas! [ par lucasd ] Je veux insérer la lib System.Data.SqlClient pour me connecter à ma db mais elle n'existe pas!!! Je suis sous Visual studio 2005. Comment ça se fait Winforms et Webservice timeout [ par calimer22 ] Bonsoir, j'ai une application winforms qui appelle des webservices mais bien sur mes webservice qui interrogent ma base SQL mettent parfois un peu de Erreur programme [ par inoussyago ] cool forum , Bonjour, à tous. salut je veux tester une classe que j'ai creer pour cela j'ai ecri ça dans mon main AccesData obj; obj = AccesData.G Une directive manquante [ par khaoula85 ] Bonsoir, Je code une application web en C#, mais au moment de la compilation, on me génère l'erreur suivante : le type ou le nom d'espace de SQLAdapte base donnée acess [ par fayrous ] Salut; dans la requete update il y a une erreur de syntax. pouvez vous m'aider. System.Data.OleDb.OleDbConnection c = new System.Data.OleDb.OleDbConn Dataset en mode design [ par thedarkkillerz ] Bonjour,  je développe actuellement une grille liée à un dataset, mais le dataset à un comportement pour le moins étrange..En effet je crée le dataset SQL serveur, espace de noms, aide svp.. [ par medinfo87 ] salut pour tous..j'ai  écri ce petit code :using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using S


Nos sponsors

Sondage...

CalendriCode

Juillet 2009
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
2728293031  

Consulter la suite du CalendriCode

Téléchargements

Logiciels à télécharger sur le même thème :

Comparez les prix Nouvelle version

Photothèque Nouveau !



Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés
Temps d'éxécution de la page : 0,452 sec

Google Coop CodeS-SourceS Google Coop CodeS-SourceS


Certaines images présentes sur le site (notament certains avatars) sont issues des collections IconShock, donc si vous souhaitez utiliser ces icons vous devez les acheter, ne les copiez pas et ne utilisez pas dans vos sites et applications sans les avoir commandé.