Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have table in Oracle
SQL
Create Table (
USERNAME                                 VARCHAR2(70),
PASSWORD                                 VARCHAR2(50),
EMAIL                                    VARCHAR2(30))


C#
namespace abc
{
    public partial class Test1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {  
            //OracleConnection ora = new OracleConnection(conn);
            //ora.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))(CONNECT_DATA=(SID=glmjoy)));User Id=glmjoy;Password=glmjoy;";
            //string qry = "insert into test1  (username) values (@txtusername)";
            //OracleCommand cmd=new OracleCommand(qry,ora);
            //cmd.Parameters.Add("username", txtusername.Text);
            //ora.Open();
            //cmd.ExecuteScalar();
            //ora.Close();
            //-----------------

            if  (!IsPostBack == true)
            { inert();
            } ----------- I  am getting error here   
         protected void inert()
         {      //If a PostBack occured, then handle your Oracle Database call

                string conn = "";

                //Create an OracleDatabase object
                OracleConnection ora = new OracleConnection(conn);
                {
                    //Open your connection
                    conn.Open();
                    
                    //Build your actual statement (example demonstrating parameters)
                    string sql = "INSERT INTO test1  (username) VALUES (@username)";

                    //Builds your command that will be executed
                    OracleCommand cmd = new OracleCommand(sql, conn);

                    //Populates your Parameters (examples)
                    cmd.Parameters.AddWithValue("@Username", txtusername.Text);


                    //Execute your command
                    cmd.ExecuteNonQuery();
                }
        }
    }
}
Posted
v4
Comments
Sebastian T Xavier 6-Dec-13 6:55am    
so what?
thatraja 6-Dec-13 7:05am    
what error? what bold? explain clearly
[no name] 6-Dec-13 7:27am    
What is the error you are getting..?

That is because you have not ended the Page Load Event...
C#
namespace abc
{
    public partial class Test1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if  (!IsPostBack)
            { 
                inert();
            }
        } // This is missing.
     
        protected void inert()
        {
            // All the function codes
        }
    }
}
 
Share this answer
 
v2
Thanks to you all for the support
 
Share this answer
 
Comments
BillW33 6-Dec-13 9:17am    
You should not post a comment to a solution or an addition to your question as a "Solution". Either add a comment to a previous solution by pressing the "Have a Question or Comment?" button or update your question by using the "Improve question" button. I did not vote, but I thought you should know why this might be downvoted.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900