Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to use ExecuteReader() with Oracle DB?

How to use ExecuteReader() with Oracle DB?

Scheduled Pinned Locked Moved C#
helpdatabaseoracletutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    babutkchn
    wrote on last edited by
    #1

    hi, In my appication i'm using Oracle as a back end. In that when i'm using ExecuteReader() it shows an exception. Can any one of help me to solve this issue. oleDBConnection = new OleDbConnection(connectString); string query = "SELECT V_FIRST_NAME,V_LAST_NAME,V_PHONE_NUMBER,V_EMAIL,V_FAX_NUMBER,V_ADDRESS,V_TITLE,V_POSTAL_CODE,V_COUNTRY from UserDetails where (V_USER_ID = ?) AND (V_PASSWORD = ?)"; OleDbCommand oledbCmd = new OleDbCommand(query, oleDBConnection); oledbCmd.CommandText = query; oledbCmd.CommandType = CommandType.Text; OleDbParameter par = oledbCmd.Parameters.Add("UserName", OleDbType.VarWChar, 50); OleDbParameter parm = oledbCmd.Parameters.Add("password", OleDbType.VarWChar, 50); oledbCmd.Parameters["UserName"].Value = userName; oledbCmd.Parameters["password"].Value = password; oledbCmd.Connection = oleDBConnection; oleDBConnection.Open(); OleDbDataReader dr ; dr = oledbCmd.ExecuteReader(); It threw an exception when executing the last line. The exception states that Unspecified error.Oracle error occured,but error message could not retrieved from Oracle.Data Type is not supported. Thanks in advance Babu

    A 1 Reply Last reply
    0
    • B babutkchn

      hi, In my appication i'm using Oracle as a back end. In that when i'm using ExecuteReader() it shows an exception. Can any one of help me to solve this issue. oleDBConnection = new OleDbConnection(connectString); string query = "SELECT V_FIRST_NAME,V_LAST_NAME,V_PHONE_NUMBER,V_EMAIL,V_FAX_NUMBER,V_ADDRESS,V_TITLE,V_POSTAL_CODE,V_COUNTRY from UserDetails where (V_USER_ID = ?) AND (V_PASSWORD = ?)"; OleDbCommand oledbCmd = new OleDbCommand(query, oleDBConnection); oledbCmd.CommandText = query; oledbCmd.CommandType = CommandType.Text; OleDbParameter par = oledbCmd.Parameters.Add("UserName", OleDbType.VarWChar, 50); OleDbParameter parm = oledbCmd.Parameters.Add("password", OleDbType.VarWChar, 50); oledbCmd.Parameters["UserName"].Value = userName; oledbCmd.Parameters["password"].Value = password; oledbCmd.Connection = oleDBConnection; oleDBConnection.Open(); OleDbDataReader dr ; dr = oledbCmd.ExecuteReader(); It threw an exception when executing the last line. The exception states that Unspecified error.Oracle error occured,but error message could not retrieved from Oracle.Data Type is not supported. Thanks in advance Babu

      A Offline
      A Offline
      Andrei Ungureanu
      wrote on last edited by
      #2

      babutkchn wrote:

      string query = "SELECT V_FIRST_NAME,V_LAST_NAME,V_PHONE_NUMBER,V_EMAIL,V_FAX_NUMBER,V_ADDRESS,V_TITLE,V_POSTAL_CODE,V_COUNTRY from UserDetails where (V_USER_ID = ?) AND (V_PASSWORD = ?)";

      You add parameters to the query, but you don't specify anywhere these parameters. Try this

      string query = "SELECT V_FIRST_NAME,V_LAST_NAME,V_PHONE_NUMBER,V_EMAIL,V_FAX_NUMBER,V_ADDRESS,V_TITLE,V_POSTAL_CODE,V_COUNTRY from UserDetails where (V_USER_ID = @UserName) AND (V_PASSWORD = @password)";

      OleDbCommand oledbCmd = new OleDbCommand(query, oleDBConnection);
      oledbCmd.CommandText = query;

      oledbCmd.CommandType = CommandType.Text;

      OleDbParameter par = oledbCmd.Parameters.Add("@UserName", OleDbType.VarWChar, 50);
      OleDbParameter parm = oledbCmd.Parameters.Add("@password", OleDbType.VarWChar, 50);

      Hope it helps.

      There are 10 kinds of people: those who understand binary and those who don't

      B 1 Reply Last reply
      0
      • A Andrei Ungureanu

        babutkchn wrote:

        string query = "SELECT V_FIRST_NAME,V_LAST_NAME,V_PHONE_NUMBER,V_EMAIL,V_FAX_NUMBER,V_ADDRESS,V_TITLE,V_POSTAL_CODE,V_COUNTRY from UserDetails where (V_USER_ID = ?) AND (V_PASSWORD = ?)";

        You add parameters to the query, but you don't specify anywhere these parameters. Try this

        string query = "SELECT V_FIRST_NAME,V_LAST_NAME,V_PHONE_NUMBER,V_EMAIL,V_FAX_NUMBER,V_ADDRESS,V_TITLE,V_POSTAL_CODE,V_COUNTRY from UserDetails where (V_USER_ID = @UserName) AND (V_PASSWORD = @password)";

        OleDbCommand oledbCmd = new OleDbCommand(query, oleDBConnection);
        oledbCmd.CommandText = query;

        oledbCmd.CommandType = CommandType.Text;

        OleDbParameter par = oledbCmd.Parameters.Add("@UserName", OleDbType.VarWChar, 50);
        OleDbParameter parm = oledbCmd.Parameters.Add("@password", OleDbType.VarWChar, 50);

        Hope it helps.

        There are 10 kinds of people: those who understand binary and those who don't

        B Offline
        B Offline
        babutkchn
        wrote on last edited by
        #3

        we are using oracle not sql server('@symbol is not supported in Oracle'). give me the solution

        A 1 Reply Last reply
        0
        • B babutkchn

          we are using oracle not sql server('@symbol is not supported in Oracle'). give me the solution

          A Offline
          A Offline
          Andrei Ungureanu
          wrote on last edited by
          #4

          Ok, my bad. But still, you have to find a way to specify the parameters in the query. I think that that's your problem.

          There are 10 kinds of people: those who understand binary and those who don't

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups