locked
Connect Oracle database and Fetch the record and Display in Asp.net RRS feed

  • Question

  • User-465685172 posted

    Hi,

    Everyone

        I have a  Project in Which i need to Fetch the Data from Oracle and display

    in RDLC report

    I need the steps how can i connect  the Asp.net

    with Oracle database

     

    Reply me

    Friday, October 7, 2011 4:38 AM

Answers

  • User1013750657 posted

    hi anand

    make sure you have oracle client installed.

    make sure you are using the namespace system.data.oracleclient from microsoft. (thats what i use. you can try others)

    add the connection string to web.config

    <connectionStrings>
            <add name="OracleConnString" connectionString="User ID=myuser;Password=mypass;Data Source=TNSALIASfromTNSFILE"/>
    </connectionStrings>

     

    then from the code behind just :

    String SqlQuery; 
    OracleConnection OraConnection = new OracleConnection(WebConfigurationManager.ConnectionStrings["OraConnectionString"].ConnectionString); 
    OracleCommand OraCommand; 
    
    SqlQuery = "Insert Into " + 
                      "mytable " + 
                      "            (myfield) " + 
                      " Values " + 
                      "            ('Hello') "; 
    
    OraCommand = new OracleCommand(SqlQuery,OraConnection); OracleDataReader OraDataReader = OraCommand.ExecuteReader(); 
    
    SqlQuery = "Select " + 
                      "       myfield " + 
                      "From " + 
                      "       mytable"; 
    
    OraCommand = new OracleCommand(SqlQuery,OraConnection); OracleDataReader OraDataReader = OraCommand.ExecuteReader(); 
    
    while(OraDataReader.Read) 
    { 
             """"whatever you want to do with the result"""" = OraDataReader["myfield"]; 
    } 
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 10, 2011 4:21 AM

All replies

  • User353943928 posted

    Please see the below link it is all about the information you need.

    Link: http://www.startvbdotnet.com/ado/oracle.aspx 

    Cheers...

    Friday, October 7, 2011 4:41 AM
  • User-465685172 posted

     

    Anand Tiwari

     

    this Link is contain the data in VB.net

    I need what all the things should i change in web.config file

    and in the Page also

    in C# Language

    Reply me

    Friday, October 7, 2011 4:46 AM
  • User1013750657 posted

    hi anand

    make sure you have oracle client installed.

    make sure you are using the namespace system.data.oracleclient from microsoft. (thats what i use. you can try others)

    add the connection string to web.config

    <connectionStrings>
            <add name="OracleConnString" connectionString="User ID=myuser;Password=mypass;Data Source=TNSALIASfromTNSFILE"/>
    </connectionStrings>

     

    then from the code behind just :

    String SqlQuery; 
    OracleConnection OraConnection = new OracleConnection(WebConfigurationManager.ConnectionStrings["OraConnectionString"].ConnectionString); 
    OracleCommand OraCommand; 
    
    SqlQuery = "Insert Into " + 
                      "mytable " + 
                      "            (myfield) " + 
                      " Values " + 
                      "            ('Hello') "; 
    
    OraCommand = new OracleCommand(SqlQuery,OraConnection); OracleDataReader OraDataReader = OraCommand.ExecuteReader(); 
    
    SqlQuery = "Select " + 
                      "       myfield " + 
                      "From " + 
                      "       mytable"; 
    
    OraCommand = new OracleCommand(SqlQuery,OraConnection); OracleDataReader OraDataReader = OraCommand.ExecuteReader(); 
    
    while(OraDataReader.Read) 
    { 
             """"whatever you want to do with the result"""" = OraDataReader["myfield"]; 
    } 
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 10, 2011 4:21 AM
  • User1013750657 posted

    of course the connection string can be alot more elaborated. you can actually copy the TNSNAMES block and pasted on the conenction string , this way you dont have to configure the TNSNAMES. all configuration is done on the web.config file.

    i should olso point that i never use the web.config file since the oracle password will be available for anyone to see.

    i normaly do a form so that the installer can insert the password , and then i save it with encription.

    if you have a db with credit card information for instance , you will fail on an audit since clear passwords are not PCI compliant.

     

    rgds

    rui

    Monday, October 10, 2011 4:25 AM