Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I want that my method return list of customer that i have created but the list that appeared is empty, please help me!!!!!!!!!!!!

there is the method that i was implemented :
public ClientTopNet CreationClient(int ID_CLIENT, string LOGIN_CREATION, DateTime DATE_CREATION, string LOGIN_MODIFICATION, DateTime DATE_MODIFICATION, int TYPE_CLIENT, int CIVILITE, string NOM, string PRENOM, string FONCTION, string RS, string CIN, string ADRESSE, string VILLE, int CP, int GOUVERN, string TEL, string GSM, string FAX, string EMAIL, int CD_ORIGINE, string OBSERV, int EXONERE, int EXOTIMBRE, int SECTEUR_ACT, int VIP, string CHARGECOMPTE, string CHARGECOMPTE_RD, int CATEGORIE, string REGISTRE, int METHOD_ENVOI_FACT, int PERSONNEL, string REF_CLIENTCRM)
        {    
           System.Data.OleDb.OleDbConnection conn = new     System.Data.OleDb.OleDbConnection();
            
           conn.ConnectionString = @"Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=topnet;Initial Catalog=TopnetBase;Data Source=SWEET-4B6F892B4\SQLEXPRESS";
           //Clients oClients = new Clients();
           ClientTopNet oClient = new ClientTopNet();
           try
           {
               conn.Open();

               int r;

               string req = "INSERT INTO client ( ID_CLIENT,LOGIN_CREATION , DATE_CREATION,LOGIN_MODIFICATION ,DATE_MODIFICATION,TYPE_CLIENT, CIVILITE,NOM,PRENOM,FONCTION,RS,CIN,ADRESSE,VILLE, CP, GOUVERN ,TEL,GSM,FAX,EMAIL,CD_ORIGINE,OBSERV,EXONERE,EXOTIMBRE,SECTEUR_ACT ,VIP, CHARGECOMPTE,CHARGECOMPTE_RD ,CATEGORIE,REGISTRE,METHOD_ENVOI_FACT,PERSONNEL,REF_CLIENTCRM )VALUES ('" + ID_CLIENT + "','" + LOGIN_CREATION + "','" + DATE_CREATION + "','" + LOGIN_MODIFICATION + "','" + DATE_MODIFICATION + "','" + TYPE_CLIENT + "','" + CIVILITE + "','" + NOM + "','" + PRENOM + "','" + FONCTION + "','" + RS + "','" + CIN + "','" + ADRESSE + "','" + VILLE + "','" + CP + "','" + GOUVERN + "','" + TEL + "','" + GSM + "','" + FAX + "','" + EMAIL + "','" + CD_ORIGINE + "','" + OBSERV + "','" + EXONERE + "','" + EXOTIMBRE + "','" + SECTEUR_ACT + "','" + VIP + "','" + CHARGECOMPTE + "','" + CHARGECOMPTE_RD + "','" + CATEGORIE + "','" + REGISTRE + "','" + METHOD_ENVOI_FACT + "','" + PERSONNEL + "','" + REF_CLIENTCRM + "')";
               System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand(req, conn);

               r = command.ExecuteNonQuery();
               conn.Close();
               return oClient;
           }
           catch (System.Data.SqlClient.SqlException ex)
           {

               string msg = "Insert Error:";

               msg += ex.Message;

               throw new Exception(msg);

           }
Posted
Updated 15-May-10 10:58am
v2

Am I missing something here? Your code inserts a record into the database, but you want to return oClient? If that's the case, your problem (in the code that you've presented) is that you instantiate oClient, and then you do nothing with it. This means that you are going to get the default state of the instantiated class back.

I would point out here, though, that you shouldn't really add your parameters to your command like this. You've left the statement wide open to a Sql Injection attack - I'd suggest that you changed it to use parameters instead.
 
Share this answer
 
thank you , it's ok now :)))))))))))
 
Share this answer
 
v2

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