Manual Loopup for Oracle database : Oracle « ADO.Net « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » ADO.Net » Oracle 
32.3.17.Manual Loopup for Oracle database
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OracleClient;
  public class MainClass
  {

    public static void Main()
    {
      OracleConnection oraConn = new OracleConnection();

      string connString = "User Id=oranetuser; Password=demo; Data Source=oranet";
      if (oraConn.State != ConnectionState.Open)
      {
        try
        {
          oraConn.ConnectionString = connString;
          oraConn.Open();
          MessageBox.Show(oraConn.ConnectionString, "Successful Connection");
        }
        catch (Exception ex)
        {
          MessageBox.Show(ex.Message,"Exception Caught");
        }
      }

      if (oraConn.State == ConnectionState.Open)
      {
        string sqlLookup = "select last_name, first_name, from PlayerTable ";
        sqlLookup += "where player_num = :player_num";

        OracleCommand cmdLookup = new OracleCommand();
        cmdLookup.CommandText = sqlLookup;
        cmdLookup.Connection = oraConn;

        OracleParameter pPlayerNum = new OracleParameter();
        pPlayerNum.DbType = DbType.Decimal;
        pPlayerNum.Value = 10;
        pPlayerNum.ParameterName = "player_num";

        cmdLookup.Parameters.Add(pPlayerNum);

        OracleDataReader dataReader = cmdLookup.ExecuteReader();

        if (dataReader.Read()){
          Console.WriteLine(dataReader.GetString(0));
          Console.WriteLine(dataReader.GetString(1));
          Console.WriteLine(dataReader.GetString(2));
          Console.WriteLine(dataReader.GetString(3));
        }else{
          MessageBox.Show("No record for Player Number Found" "No Record Found");
        }

        dataReader.Close();
        dataReader.Dispose();
        cmdLookup.Dispose();
      }
    }
  }
32.3.Oracle
32.3.1.how to use an OleDbConnection object to connect to an Oracle database
32.3.2.A connection string using integrated security for Oracle database
32.3.3.A connection string without integrated security for Oracle database
32.3.4.Get connection state and server version
32.3.5.Using OracleCommand to do query
32.3.6.Using OracleCommand to do the query sql
32.3.7.Using OracleCommandBuilder
32.3.8.Using OracleDataAdapter
32.3.9.Using OracleDataReader to read from Oracle database
32.3.10.Using OracleParameter
32.3.11.Connect to an Oracle Database using .NET data provider for OLE DB
32.3.12.Connect to an Oracle Database using OdbcConnection
32.3.13.Connecting to an Oracle Database with OracleConnection
32.3.14.Do a delete command to Oracle database
32.3.15.Do an insert command to Oracle database
32.3.16.Do an update to Oracle database
32.3.17.Manual Loopup for Oracle database
32.3.18.Read string from OracleDataReader
32.3.19.Use OracleConnection to connect to Oracle database
32.3.20.Rollback for Oracle database
32.3.21.Runs the CustomerAdd stored procedure.
32.3.22.No Connection Pooling
32.3.23.Read decimal from OracleDataReader
32.3.24.Connection String for Oracle database
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.