Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
born2acheive
Yak Posting Veteran
65 Posts |
Posted - 2006-12-05 : 04:17:50
|
| hi,i am using c# asp.net with sqlserver. so i a m inserting values from front end to back end.my need is i have to create logfile at which time i inserted,in which table i inserted,who is inserted and which operation performed.so these things i have to maintain in log file.this is my need.actually i tried this by the following way:i created the table log:which cotains the following field.name,desc,tablename,datethen i created one stored procedure :code:CREATE PROCEDURE splog(@name varchar(50),@desc varchar(50),@tabname varchar(50), @date datetime) Asbegininsert into log values(@name,@desc,@tabname,getdate())endGOthen i created stored procedure for insert as follows:CREATE PROCEDURE spemp1insert(@name varchar(50),@age int,@id int) Asbegininsert into emp1 values(@name,@id,@age)if(@@error=0)beginexecute splog @name='karthikeyan',@desc='insertoperation',@tabname='emp1'endendGObut if i inserted my record from c#asp.net to sqlserver the record getting inseretd,but in the log table the is is no value.so please tel me what problem i did,please help me to do this,please |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-12-05 : 04:51:51
|
| Write INSERT trigger on corresponding table(s) (in this case emp1) and insert audit data in Log table from the trigger.Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
|
born2acheive
Yak Posting Veteran
65 Posts |
Posted - 2006-12-05 : 05:33:54
|
| hi harsh_athalye the above code worked i got that.any way thanks for your reply.one more help i did that if i inserted the data the log file will have the value.i need one more sugestion.if the database error comes while running my project that has to be stored in another table.for example if i run my project executenonquery error may occur if my inputs age not valid.so i have to maintain this also.just view my spc in that i mentioned if(@@error==0) operation.so i need if error not equal to zero then operation.so please give me syntax for not qual to zero. |
 |
|
|
|
|
|
|
|