2
Reply

[C#2003] type dataset

philo neo

philo neo

Mar 8 2006 7:30 AM
2.1k
Hi,
I do a application with C# and SQL server 2000, I have a question about type dataset,
i have 4 tables that a modélise with type dataset, the name is "Dataset_command".
I think that i do a mistake betwen sqladapter and sqlcommad, can you help me?
This is my code :

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.SqlClient;
//using System.Data.SqlClient.SqlDataAdapter;
using System.Data;
......

protected const string SQL_CONNECTION_STRING = "Server=localhost;DataBase=philo_es;Integrated Security=SSPI";
protected const string MSDE_CONNECTION_STRING = "Server=(local)\\NetSDK;DataBase=philo_es;Integrated Security=SSPI";
protected const string CONNECTION_ERROR_MSG = "To run this sample, you must have SQL or MSDE with the Northwind database installed. For instructions on installing MSDE, view the ReadMe file.";
protected bool bolDidPreviouslyConnect = false;
protected bool bolDidCreateTable = false;
protected string connectionString = SQL_CONNECTION_STRING;
.....

// affichage du select

SqlConnection connexion = new SqlConnection(connectionString);
SqlDataAdapter macomclient =
new SqlDataAdapter("SELECT num_client ,nom_client , prenom_client, adr_client , tel_client FROM table_client ",connexion);
//SqlCommand macomclient = new SqlCommand("SELECT num_client ,nom_client , prenom_client, adr_client , tel_client FROM table_client ",connexion);
macomclient.Connection=connexion;
SqlDataAdapter m_sqladapter =
new SqlDataAdapter();
//Création du Premier DataAdpater pour la Table commande
//SqlDataAdapter daCommande = new SqlDataAdapter("SELECT num_commande,num_c_client,num_c_ligne_commande, desi_commande FROM table_commande",connexion);
try
{
m_sqladapter.SelectCommand = macomclient;
connexion.Open();
//connexion.ExecuteNonQuery();
Dataset_command dsGestion = new Dataset_command();
//dsSeafood.Clear();
daClient.Fill(dsGestion, "table_client");
//daClient.Fill(dsGestion, "table_client");
//daClient.DataSource = dsGestion;
//daClient.DataMember = "table_client";
//daCommande.Fill(dsGestion, "table_commande");


Answers (2)