1 pièce(s) jointe(s)
Connexion entre Visual Studio et Oracle
Bonjour tous le monde;
J'ai un visual studio 2010 et oracle10g j'arrive pas à établir une connexion entre le visual studio et l'oracl
mon code est le suivant:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| using System;
using System.Collections.Generic;
using System.Text;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
using System.Data;
namespace TP3
{
static class Connection
{
private static string SQL;
private static OracleConnection conn;
private static OracleCommand cmd;
private static OracleDataAdapter da;
private static DataSet ds;
//_____________________________________________________________________//
// Première méthode
public static string Connect()
{
try
{
string oradb = "Data Source= XE ;User Id=system;Password= orcl1;";
conn = new OracleConnection(oradb);
conn.Open();
Console.WriteLine("connex reussi");
}
catch (OracleException e)
{
return e.Message;
}
return conn.State.ToString();
}
//_____________________________________________________________________//
// Deuxième méthode
public static void GetEtudiants()
{
SQL = "SELECT * FROM Etudiant";
cmd = new OracleCommand(SQL, conn);
cmd.CommandType = CommandType.Text;
da = new OracleDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
/* Affichage du contenu de la table */
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
Console.WriteLine(ds.Tables[0].Rows[i][0].ToString() + "\t\t" +
ds.Tables[0].Rows[i][1].ToString() + "\t\t" +
ds.Tables[0].Rows[i][2].ToString());
}
Console.WriteLine("________________________________________________");
Console.WriteLine();
}
//_____________________________________________________________________//
// Troisième méthode
public static int PutEtudiants()
{
SQL = "INSERT INTO Etudiant VALUES (9,'x', 'y')";
cmd = new OracleCommand(SQL, conn);
cmd.CommandType = CommandType.Text;
da = new OracleDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
Connection.GetEtudiants();
return (ds.Tables[0].Rows.Count);
}
//_____________________________________________________________________//
// Quatrième méthode
public static void Terminate()
{
conn.Close();
}
//_____________________________________________________________________//
}
} |
Pièce jointe 223806
S'il vous plais aidez moi à résoudre c problème sachant que j'ai rajouté le fichier dll comme référence
et merci d'avance