Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > Oracle
|
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 15th, 2008, 12:42 AM
MZA MZA is offline
Registered User
 
Join Date: Dec 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default C# and oracle

I can't connect oracle with C#.I use oracle 10g,ODP.NET,VS.net2005.
I add refferrence to Oracle.DataAccess
And this is my code:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.client;

namespace winOra
{
    public partial class frmShow : Form
    {
        public frmShow()
        {
            InitializeComponent();
        }

        private void btnShow_Click(object sender, EventArgs e)
        {


            string oradb = "Data Source=(DESCRIPTION=(ADDRESS_LIST="
                     + "(ADDRESS=(PROTOCOL=TCP)(HOST=OTNSRVR)(PORT=1521)) )"
                     + "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORC L)));"
                     + "User Id=ebezer;Password=ebazar;";

            OracleConnection conn = new OracleConnection(oradb);
            conn.Open();

            OracleCommand cmd = new OracleCommand();
            cmd.Connection = conn;
            cmd.CommandText = "select name from INFO where RegNo = 2003331009";
            cmd.CommandType = CommandType.Text;

            OracleDataReader dr = cmd.ExecuteReader();
            dr.Read();
            lblShow.Text = dr.GetString(0);

            conn.Dispose();
        }
    }
}
...........................
accualy i am extremly new!
Can any one help me,Plz?
 
Old January 15th, 2008, 03:55 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

So waht does happen? Is there an error message etc?


--

Joe (Microsoft MVP - XML)
 
Old January 15th, 2008, 05:27 AM
MZA MZA is offline
Registered User
 
Join Date: Dec 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

my compiler can't understand the last using statement:

using oracle.dataAccess;




 
Old January 15th, 2008, 05:32 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

It should be
Code:
using Oracle.DataAccess.Client;
--

Joe (Microsoft MVP - XML)
 
Old January 15th, 2008, 01:39 PM
MZA MZA is offline
Registered User
 
Join Date: Dec 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Joefawcett for your kind help.This problem is solved ,but another problem is introduced.I will message it later. I have not have much clear concept about the connection string.Can you please help me about this.

 
Old January 16th, 2008, 04:08 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

There are examples at www.connectionstrings.com.

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Oracle SOA, BPEL and Oracle worklist umeshtheone Pro Java 1 April 16th, 2008 11:01 PM
call oracle function using oracle link server vl SQL Server 2000 1 July 12th, 2007 08:19 AM
How to Read Oracle Data without Oracle being insta badrinarayanang Oracle 1 October 6th, 2005 06:34 AM
Connecting to Oracle without Oracle Client mahaveerar VB Databases Basics 0 February 22nd, 2005 05:18 PM
Connecting to Oracle without Oracle Client mahaveerar Excel VBA 0 February 22nd, 2005 03:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.