• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

ODBC and Oracle

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone,

I am trying to create an application with ODBC compliant code for DB business logic is in c#  DBs to use are oracle 12c and 11g and MSSQL

I am using ADO.NET, OLEDB, ODP.NET , ODBC etc.

Problem is when i try to use the ODBC code with oracle 12C where i am getting cast errors and other errors,I have tried IDbConeection, IDbCommand etc but they have a problem in case of Oracle (Ref Cursor) and data types of different databases and also there is problem with the DBTypes because they are enum define differently with different data providers.

for example, for boolean, the links below show i can use SQL_BIT as ODBC type but it's not even showing up in the intellisense

https://docs.oracle.com/cd/E15817_01/server.111/e10311/apa.htm

https://docs.oracle.com/cd/B19306_01/server.102/b14232/apb.htm

Can I use the same code against the Oracle database, without code change? Because some of the datatypes in Oracle and SQL Server are quite different,  and code also throws error.

Is there any way to achieve this? Some link or guide would be appreciated.

here is below example it is working in MSSQL but its not working with oracle database . it gives me invalid datatype error of boolean.

string strQuery = "SELECT remember_me, forgot_password, throttle_auth, maximum_attempts, company_name FROM tbl_settings";
               var ds = dbManager.GetDataSet(strQuery, CommandType.Text,null);
              ds = DataControl.GetDataSet(strQuery);
               if (ds.Tables[0].Rows.Count > 0)
               {
                   if (bool.Parse(ds.Tables[0].Rows[0]["remember_me"].ToString()) == true)
                   {
                       divRememberMe.Visible = true;
                       rememberMe = true;
                   }
                   else
                   {
                       divRememberMe.Visible = false;
                       rememberMe = false;
                   }
                }

 
Saloon Keeper
Posts: 15727
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I can tell, Oracle doesn't have booleans.

First converting a field to string and then parsing it doesn't really make sense. Parsing also expects the parsed string to be in the correct format for the expected data type, so if you parse "1" it won't lead to the boolean value true.

Instead of converting the value from the database to string, see if you can use Convert.ToBoolean() instead.
 
Drove my Chevy to the levee but the levee was dry. A wrung this tiny ad and it was still dry.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic