public static void AddNewStudent(int Stu_id, string Stu_Name, string Class, string Major, Datetime Enddate)
{
OracleDatabase db =(OracleDatabase)DatabaseFactory.CreateDatabase("PHTS");
using (System.Data.Common.DbCommand cmd = db.GetStoredProcCommand("AddNewStudent"))
{
db.AddInParameter(cmd, "I_Stu_id", DbType.Int32, Stu_id);
db.AddInParameter(cmd, "I_Stu_Name", DbType.String, Stu_Name);
db.AddInParameter(cmd, "I_Class", DbType.String, Class);
db.AddInParameter(cmd, "I_Major", DbType.String, Major);
db.AddInParameter(cmd, "I_Enddate", DbType.Date, Enddate, Enddate == null? DBNull.Value : Enddate);
db.ExecuteNonQuery(cmd);
}
}
User Interface
private void Savebutton_Click(object sender, EventArgs e)
{
private void Savebutton_Click(object sender, EventArgs e)
{
int student_id = Convert.ToInt32(this.SIDtextBox.Text);
string stu_name = this.textBox1.Text;
string class = this.textBox2.Text;
string major= this.textBox3.Text;
Datetime enddate = Datetime.Parse(this.textbox4.text);
if (this.textbox4.Text == "")
{
enddate = null;
}
else
{
enddate = DateTime.Parse(this.textbox4.Text);
}
PHTS.DataServices.cslMaterial.AddNewStudent(stu_id, stu_name, class, major, enddate);
MessageBox.Show("Record Saved");
}
}
}
Procedure
Create or replace PRPCEDURE AddNewStudent (
I_STU_ID Number,
I_STU_Name Varchar2,
I_Address Varchar2,
I_Phone Varchar2,
I_Enddate date,
)
As
Begin
Insert into I_Student
(
Student_ID, STU_Name, Address, Phone, Enddate
)
Values
(
I_Student_ID, I_STU_Name, I_Address, I_phone, I_Date , I_Enddate
);
Finally I got it thanks for helping