Comment connecter une application C# à une base de données Oracle

Lorsque vous créer une application C# (C Sharp), vous serez surement amené à communiquer avec une base de données. Dans ce tutoriel, je vais vous donner le code source pour effectuer une connexion simple à une base de données Oracle.

J’utilise les programmes suivants :

 Ajout de référence(s)

Etape 1 : Ajouter la référence Oracle

Pour commencer, il faut ajouter la référence du client Oracle à votre projet. Pour ça, sur votre droite, vous devriez avoir l’explorateur de solutions (voir screenshot ci-dessous). Si ce menu n’apparaît pas, allez dans “Affichage” puis “Explorateur de solutions” ou faites un CTRL+W,S.


Faites un clique-droit sur “Références”, “Ajouter une référence…”


Cochez “System.Data.OracleClient” et validez par OK

 Ajout du code source dans votre projet

Etape 2 : Le bout de code de connexion

Vous n’aurez plus qu’à insérer les deux méthodes ci-dessous dans une classe de votre projet. Vous pourrez appeler ces méthodes lors d’un clic sur un bouton ou à l’initialisation d’une fenêtre.

public void connexionOracle()

string oradb = "Data Source=NOMDELABASE;User Id=IDENTIFIANT;Password=MOTDEPASSE;";
OracleConnection conn = new OracleConnection(oradb);

// Ouverture de la connexion

// Avec ce IF je test l’état de la connexion et j’affiche si CONNECTE ou NON CONNECTE
if (conn.State.ToString() == "Open")
labelStatutConnOracle.Text = "Connecté";
labelStatutConnOracle.Text = "Non Connecté";

public void deconnexionOracle()

N’oubliez pas de remplacer les valeurs dans la chaine oradb à la ligne 4 en mettant la nom de votre base de données Oracle, votre identifiant et votre mot de passe (le même que vous utilisez pour réaliser une connexion avec SQL Developer par exemple).

Le label “labelStatutConnOracle” me permet de visualiser dans la fenêtre, l’état de ma connexion à ma base de données (“Connecté” ou “Non connecté”)

Maintenant que votre connexion est active, vous pouvez balancer vos requêtes selon vos besoins!

35 Comments Comment connecter une application C# à une base de données Oracle

  1. Brittney

    hey there and thank you for your info – I have certainly picked up
    something new from right here. I did however expertise some technical issues using this web site, since I experienced
    to reload the site lots of times previous to I could get it to load
    properly. I had been wondering if your web hosting is OK?
    Not that I am complaining, but slow loading instances times will very
    frequently affect your placement in google and could damage your high quality score if advertising and marketing
    with Adwords. Well I’m adding this RSS to my email and could look out for much more of your respective interesting content.
    Make sure you update this again very soon.

  2. sky1388 android download

    Hi I am so grateful I found your blog page, I
    really found you by error, while I was researching on Aol for
    something else, Regardless I am here now and would just like to say kudos for a marvelous post and a all round
    thrilling blog (I also love the theme/design), I don’t have time to read it all
    at the minute but I have book-marked it and also added your RSS feeds, so when I have time I will be back to read a lot more, Please do keep up the fantastic work.

    Also visit my web blog: sky1388 android download

  3. 3win8 online

    Hi there! I understand this is sort of off-topic but I needed to ask.
    Does operating a well-established blog such as yours take a massive amount work?
    I’m completely new to writing a blog but I do write in my journal everyday.
    I’d like to start a blog so I can easily share my
    experience and views online. Please let me know if you have any suggestions or tips for new aspiring bloggers.
    Appreciate it!

    Stop by my homepage … 3win8 online

  4. Apl Aaa1188

    The other day, while I was at work, my sister stole my apple ipad and
    tested to see if it can survive a 30 foot drop, just so she
    can be a youtube sensation. My apple ipad is now broken and she has 83 views.
    I know this is completely off topic but I had to share it
    with someone!

    My blog … Apl Aaa1188

  5. 99online joker123

    Saya akan segera pegang rss feed Anda karena saya tidak bisa
    Ini adalah waktu sempurna untuk membuat beberapa rencana untuk masa depan dan sekarang
    waktu untuk berbahagia. Saya telah membaca posting ini dan jika saya bisa, saya ingin menyarankan Anda beberapa hal menarik
    atau tips. Mungkin Anda bisa menulis artikel berikutnya yang mengacu pada artikel ini.
    Saya ingin membaca lebih hal tentang itu!

    Also visit my web-site 99online joker123

  6. puccy888

    Wonderful blog! I found it while searching on Yahoo News.
    Do you have any tips on how to get listed in Yahoo News?

    I’ve been trying for a while but I never seem to get there!

    Also visit my site puccy888

  7. rollex11 pc download

    Definitely consider that which you stated. Your favorite justification seemed to be on the net the simplest factor to consider of.

    I say to you, I certainly get annoyed whilst other folks
    think about concerns that they just do not realize about.
    You controlled to hit the nail upon the top and also outlined out the whole thing with no need
    side effect , other people can take a signal. Will probably be again to
    get more. Thank you

    Also visit my blog post: rollex11 pc download

  8. Tiffany

    Excellent blog here! Also your site loads up very fast!
    What host are you using? Can I get your affiliate link to your host?

    I wish my website loaded up as fast as yours lol

    Feel free to surf to my page: jackpot calibet (Tiffany)

  9. test playboy2

    Great post. I was checking continuously this weblog and I’m impressed!

    Very helpful info particularly the final section 🙂 I take care
    of such info a lot. I used to be looking
    for this certain info for a very long time. Thank you and good luck.

    Have a look at my homepage :: test playboy2

  10. Joker123ne

    Saya telah telah berselancar online lebih dari tiga jam hari
    ini, namun saya tidak pernah menemukan artikel menarik seperti milik Anda.
    It is cukup berharga bagi saya. Menurut pendapat saya , jika semua pemilik situs dan blogger membuat konten yang baik seperti yang Anda lakukan, web akan menjadi a jauh
    lebih berguna dari sebelumnya.

    Feel free to surf to my webpage … Joker123ne

  11. wm casino online

    I know this if off topic but I’m looking into starting my own blog and was
    curious what all is required to get setup? I’m
    assuming having a blog like yours would cost a pretty penny?

    I’m not very web savvy so I’m not 100% certain. Any recommendations or advice would be
    greatly appreciated. Cheers

    Visit my web-site … wm casino online

  12. baca disini

    This is a great tiip particularly to those fresh to the blogosphere.
    Ꮪimple but very ɑccuгate info… Appreciate
    your ѕharing this one. A must resd pօst!


Leave a Reply

Your email address will not be published.