Click here to Skip to main content
13,707,319 members
Rate this:
 
Please Sign up or sign in to vote.
Hi,

I am trying to connect Visual studio 2013 project with Oracle db using selenium scripting. It's throwing error as follows:

Test Name: #testscript_Test
Test FullName: #Project.#Test.#testscript.#testscript_Test
Test Source: c:\Users\username\Documents\Visual Studio 2013\Projects\#Project\#Project\#Test\#testscript.cs : line 62
Test Outcome: Failed
Test Duration: 0:00:31.5473491

Result Message:
Test method #Project.#Test.#testscript.#testscript_Test threw exception:
System.InvalidOperationException: Internal .Net Framework Data Provider error 30.
Result StackTrace:
at System.Data.ProviderBase.DbBuffer.Validate(Int32 offset, Int32 count)
at System.Data.ProviderBase.DbBuffer.PtrToStringUni(Int32 offset)
at System.Data.OracleClient.OciHandle.PtrToString(NativeBuffer buf)
at System.Data.OracleClient.OracleInternalConnection.get_ServerVersion()
at System.Data.OracleClient.OracleInternalConnection.get_ServerVersionNumber()
at System.Data.OracleClient.OracleInternalConnection.get_ServerVersionAtLeastOracle8()
at System.Data.OracleClient.OracleConnection.get_ServerVersionAtLeastOracle8()
at System.Data.OracleClient.OracleColumn.Describe(Int32& offset, OracleConnection connection, OciErrorHandle errorHandle)
at System.Data.OracleClient.OracleDataReader.FillColumnInfo()
at System.Data.OracleClient.OracleDataReader..ctor(OracleCommand command, OciStatementHandle statementHandle, String statementText, CommandBehavior commandBehavior)
at System.Data.OracleClient.OracleCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.OracleClient.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at #Project.dbconnection.Databaseconnection.ExecuteSQL(OracleConnection connection, String sqlQuery) in c:\Users\username\Documents\Visual Studio 2013\Projects\#Project\#Project\dbconnection\Databaseconnection.cs:line 37
at #Project.#Test.#testscript.readDataFromDatabase() in c:\Users\username\Documents\Visual Studio 2013\Projects\#Project\#Project\#Test\#testscript.cs:line 79
at #Project.#Test.#testscript.#testscript_Test() in c:\Users\username\Documents\Visual Studio 2013\Projects\#Project\#Project\#Test\#testscript.cs:line 63

_____________________________________________________________________
Class 1 is :
class Databaseconnection
    {

       
        public OracleConnection ConnectToOracleDB(String username, String password, String dbname)
        {
            String connectionString = "Data Source=" + dbname + ";Persist Security Info=True;" +
                                      "User ID=" + username + ";Password=" + password + ";Unicode=True";
            OracleConnection conn = new OracleConnection(connectionString);
            //conn.ConnectionString = connectionString;
            conn.Open();
            return conn;
        }

        
        public DataTable ExecuteSQL(OracleConnection connection, String sqlQuery)
        {
            OracleCommand command = new OracleCommand();
            command.Connection = connection;
            command.CommandText = sqlQuery;
            command.CommandType = CommandType.Text;
            //OracleDataReader oraDataReader = command.ExecuteReader();
            OracleDataAdapter oDA = new OracleDataAdapter(command);
            DataSet ds=new DataSet();
            oDA.Fill(ds);
            DataTable table = new DataTable();
            table=ds.Tables[0];
            return table;
        }
    }
}

__________________
class 2 is :


 public class #testscript 
    {
        
        public #testscript()
        {
            
        }


        

     
       public void #testscript_Test()
        {
            readDataFromDatabase();

            
          
        }
       

        public void readDataFromDatabase()
        {
            Databaseconnection rd = new Databaseconnection();
            OracleConnection con = rd.ConnectToOracleDB("name", "name", "name");
           
            String query = "select * from table";
            DataTable table = rd.ExecuteSQL(con, query);((((getting error when control reaches this line))))))
            //return table;
            con.Close();
        }


    }
}





Thanks!!!
Posted 11-Jan-16 2:13am
Updated 11-Jan-16 2:20am
v3

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
11-Jan-16 8:53am
   
Thanks for the immediate reply Abhinav. I just went through the links , they point Incorrect operations with data types on the Oracle side is also result for this error message. I am new to C#/Visual studio and not able to figure out the mistake still. Will appreciate if you can help a bit more.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web06-2016 | 2.8.180920.1 | Last Updated 11 Jan 2016
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100