Click here to Skip to main content
15,904,416 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public static void AddNewInventory(string stu_name, string address, string Phone, string date)
        {
            string sql = "BEGIN Insert into I_Student " +
                "(Student_ID, STU_Name, Address, Phone, DATE )" +
                    "Values(I_Student_ID.NextVAL, :STU_Name, :Address, :Phone,to_date(:DATE, 'MM/DD/YYYY HH24:MI:SS')); END; ";

            Console.WriteLine("Insert SQL = " + sql.ToString());
            OracleDatabase db = (OracleDatabase)DatabaseFactory.CreateDatabase("PHTS");

            using (System.Data.Common.DbCommand cmd = db.GetSqlStringCommand(sql))
            {


                db.AddInParameter(cmd, "STU_Name", DbType.String,stu_name);
                db.AddInParameter(cmd, "Address", DbType.String,address);
                db.AddInParameter(cmd, "Phone", DbType.String,Phone);
                db.AddInParameter(cmd, "DATE", DbType.String,date);

               db.ExecuteNonQuery(cmd);

            }

        }
    }



How can I bind the auto generated number to a textbox
Posted
Updated 28-Jul-11 8:06am
v4

You're not setting the address field.

I suspect now that the Student_ID field is the issue.
 
Share this answer
 
v2
Comments
RaisKazi 27-Jul-11 14:00pm    
Agree. 5!
RaisKazi 27-Jul-11 14:04pm    
Also Parameters declared in Query and below added parameters are not matching.
rbjanaki 27-Jul-11 14:20pm    
I did set the address field. I don't understand the problem either
If Student_ID is an auto I'd column leave it out of the insert
 
Share this answer
 
Have a look at This[^]

hope it helps :)
 
Share this answer
 

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