Bonjour,
je suis debutant avec c sharp et je rencontre ce pb et ces erreurs :
ORA-12154: TNS:could not resolve the connect identifier specified et aussi
.\r\n ORA-00911: caractère non valide
voici mon code:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Data;
using System.Data.OleDb;
namespace ProjetETL
{
public class ExtractLoadOracle : ExtractLoad
{
public ExtractLoadOracle()
{
}
public ExtractLoadOracle(String source,String destination,String connexion)
{
strconnexion = connexion;
strdestination = destination;
strsource = source;
}
public override ArrayList extract()
{
string connectionString = "provider=MSDAORA;Data Source=ORCL;User Id=system;Password=database";
OleDbConnection myOleDbConnection = new OleDbConnection(connectionString);
//OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand();
myOleDbConnection.Open();
string requete = "select * from etudiant where id_etu between 3500 and 3600;";
/* OleDbDataAdapter adapter = new OleDbDataAdapter(requete, myOleDbConnection);
DataSet dataset = new DataSet();*/
// myOleDbCommand.CommandText = "select * from etudiant where id_etu between 3500 and 3600;";
OleDbCommand myOleDbCommand= new OleDbCommand(requete, myOleDbConnection);
ArrayList contenubase = new ArrayList();
/*int i = dataset.Tables["etudiant"].Rows.Count;
for (int j = 0; j < i; j++)
{
Etudiant etu = new Etudiant();
string id = dataset.Tables[1].Rows[j]["ID_ETU"].ToString();
etu.setId (Int32.Parse(id));
etu.setNom(dataset.Tables[1].Rows[j]["NOM_ETU"].ToString());
etu.setPrenom(dataset.Tables[1].Rows[j]["PRENOM_ETU"].ToString());
contenubase.Add(etu);
}*/
OleDbDataReader reader = myOleDbCommand.ExecuteReader();
while (reader.Read())
{
Etudiant etu = new Etudiant();
etu.setId(reader.GetInt32(1));
etu.setNom(reader.GetString(2));
etu.setPrenom(reader.GetString(3));
contenubase.Add(etu);
//etu.setId(rs.getInt(1));
//etu.setNom(rs.getString(2));
//etu.setPrenom(rs.getString(3));
//contenuBase.add(etu);
//ArrayList List = new ArrayList();
}
Console.WriteLine("Etat de la connexion : " + myOleDbConnection.State);
myOleDbConnection.Close();
return contenubase;
}
public override void load(ArrayList contenubase)
{
string connectionString = "provider=MSDAORA;Data Source=ORCL;User Id=system;Password=rahim";
OleDbConnection myOleDbConnection = new OleDbConnection(connectionString);
OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand();
while (contenubase != null)
{
Etudiant e = new Etudiant();
String requete = "INSERT into etudiant VALUES (" + e.getId() + ",'" + e.getNom() + "','" + e.getPrenom() + "')";
}
}
}
}