Thursday, 15 April 2010

c# - How to send updates of item to database in DotNetNuke Module? -



c# - How to send updates of item to database in DotNetNuke Module? -

i new dotnetnuke , creating new module , trying figure out best way upload info in database is.

i used code:

public void updatestudentbyid(int studentid, pupil student) { using (idatacontext ctx = datacontext.instance()) { var rep = ctx.getrepository<student>(); rep.update(student); } }

but problem didn't update in database , when checked sql profile found generated query:

exec sp_executesql n'update [attendance_students] set [surname] = @0, [givennames] = @1, [birthdate] = @2, [gender] = @3, [address1] = @4, [address2] = @5, [state] = @6, [postcode] = @7, [notes] = @8, [createdbyuserid] = @9, [lastmodifiedondate] = @10 [studentid] = @11',n'@0 nvarchar(4000),@1 nvarchar(4000),@2 datetime,@3 nvarchar(4000),@4 nvarchar(4000),@5 nvarchar(4000),@6 nvarchar(4000),@7 nvarchar(4000),@8 nvarchar(4000),@9 int,@10 datetime,@11 int',@0=n'good',@1=n'good',@2='2013-02-20 00:00:00',@3=n'male',@4=n'dsfdfsdfdf',@5=n'',@6=n'sa',@7=n'',@8=n'good',@9=1,@10='2013-02-15 02:58:39.047',@11=0

it's obvious query there no status produced update specific item.

so best way update object database?

you passing in pupil object doesn't have studentid property set value -- that's why criteria trying update studentid = 0. set value before calling function , should go.

and doing this, won't need phone call updatestudentbyid passing both studentid , student, rather phone call updatestudent , pass student.

... //before calling updatestudent, create sure studentid property set student.studentid = 123; .... public void updatestudent(student student) { using (idatacontext ctx = datacontext.instance()) { var rep = ctx.getrepository<student>(); rep.update(student); } }

hope helps.

c# sql dotnetnuke

No comments:

Post a Comment