What i am trying to do is, update the SQL DB through the NHibernate objects.
I do a series of steps to Add a new instance of my table object, save the that object and then flush it as shown below. I have tried 2 ways to append the changes to DB. First way is to BegingTransaction-->commit-->close
The second way i have tried is, save()-->flush()
Code:
ITransaction transaction = Session.BeginTransaction();
BrunMainPost dt = (BrunMainPost)Session.Get(
typeof(BrunMainPost), Rvs.PostDt);
dt.RVSData.Add(Rvs);
Session.Save(dt);
transaction.Commit();
Session.Close();
//Session.Flush();
return dt;
Every thing works fine until Save.
However the moment i step over to either the Session.Flush() OR transaction.commit(), i get an exception that says the following:
Message = NHibernate:
"could not update: [Muni.DataAccess.Brunello.MainRVS#0]
[SQL: INSERT INTO MainRVS
(cusip, dated_date, name, adv_rfnd_dt, brunpost_dt, id)
VALUES
(?, ?, ?, ?, ?, ?)]
These(cusip, dated_date, name, adv_rfnd_dt, brunpost_dt, id) are the Column fields that my table object has.
Now when i step ove rthese errors, and try running the application again, i get the following error
System.NullReferenceException' occurred in System.Windows.Forms.dll - Object reference not set to an instance of an object.
I drilled down in this error and find out that there is an inner exception in the above error, that says the following (i am only included 6 properties instead of 42 that are in the error to save the space here):
Inner Exception: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
Can someone help me out here, what could be wrong?
(1) I am using sql DB
(2) There are 2 tables that i am using.
- table 2 has 42 columns and table 2 has 2 columns.
- the table 2 is connected with table 1 through a Foreign Key.
(3) In table 1 and in table 2, there is a DateTime column that is set to "
Not Allow Nulls"
What do you guys think?