GIDForums  

Go Back   GIDForums > Computer Programming Forums > .NET Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 31-Oct-2009, 21:17
shyam_oec shyam_oec is offline
New Member
 
Join Date: Jan 2008
Posts: 17
shyam_oec has a little shameless behaviour in the past
Thumbs up

Runtime error returned by Oracle, while inserting


Dear sir,
i am new to ASP.NET programming ,through c#.
In my web project,i am inserting into SqlServer Database through Command.Text method.It is working fine.
Below i am giving the code for SqlServer database table.

C-SHARP / C# Code:
...
....
using System.Data.SqlClient;


public partial class _Default : System.Web.UI.Page
{
    SqlConnection sqlcon = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=DB2;Integrated Security=True;Pooling=False");
    protected void Page_Load(object sender, EventArgs e)
    {
        GridControl();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        String sqlins = "insert into emp_t values(@emp_name)";  
        SqlCommand sqlcmd = new SqlCommand();
        sqlcmd.Connection = sqlcon;
        sqlcmd.CommandText = sqlins;
        sqlcmd.CommandType = CommandType.Text;
        sqlcmd.Parameters.Add("@emp_name", TextBox1.Text.ToString());
        sqlcon.Open();
        sqlcmd.ExecuteNonQuery();
        sqlcon.Close();
        Response.Write("record saved");

        GridControl();
    }
    public void GridControl()
    {
        String sqlsel = "select *from emp_t";
        SqlDataAdapter sda = new SqlDataAdapter(sqlsel, sqlcon);
        DataTable dt = new DataTable();
        sda.Fill(dt);
        GridView1.DataSource = dt;
        GridView1.DataBind();

    }

}

this is working fine....BUT when i tried to do so in Oracle DataBase table it gave error.Exception is returned by Oracle database.Below is the cose for Oracle DataBase table

C-SHARP / C# Code:
...
.....
using System.Data.OracleClient;



public partial class _Default : System.Web.UI.Page
{
    OracleConnection oracon = new OracleConnection("Data Source=EARTH;Persist Security Info=True;User ID=rinku;Password=rinku;Unicode=True");
   
    protected void Page_Load(object sender, EventArgs e)
    {
        GridControl();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        String orains = "insert into T6 values(@name)";

        OracleCommand oracmd = new OracleCommand();
        oracmd.Connection = oracon;
        oracmd.CommandText = orains;
        oracmd.CommandType = CommandType.Text;
        oracmd.Parameters.Add("@name", TextBox1.Text.ToString());
        oracon.Open();
        oracmd.ExecuteNonQuery();
        oracon.Close();
        Response.Write("Record saved");
        GridControl();
        
    }
    public void GridControl()
    {
         String orasel="select *from T6";
         OracleDataAdapter oda = new OracleDataAdapter(orasel, oracon);
         DataTable dt = new DataTable();
         oda.Fill(dt);
         GridView1.DataSource = dt;
         GridView1.DataBind();

    }


}

.
Build is successful but,
It gave the following runtime error:-
Error at : oracmd.ExecuteNonQuery();
OracleException was unhandled by the user code
ORA-01036: illegal variable name/number

plz help me ...
Last edited by LuciWiz : 31-Oct-2009 at 23:13. Reason: Please insert your C# code between [c#] & [/c#] tags
 
 

Recent GIDBlogAccepted for Ph.D. program by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime Error 21 n10doefrk Computer Software Forum - Windows 3 26-Sep-2008 04:56
How to Suppress Runtime Error Dialog Box js_63042 MS Visual C++ / MFC Forum 0 21-Jul-2008 14:30

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 00:26.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.