hi,
,i need to create database which has few tables, suppose,one table name is "master_tables" which has table_id and table_name(columns)(table_name column is which all the tables names which is in db).
suppose there is table name employee which has emp_id, name ,address + two more columns names loghistory_id and tablerow_id..(tablerowid value come from master_tables table_id).. and another table is log_history_table..(which has loghistoryid,tablerowid,rowid,operation(insert,delete,update etc),user_name(application user name),comments) if i insert record through asp.net application,after inserting successfully, the record should be inserted in both the tables means (in inserted table + log historytable)...in log history table i want..tablerowid of table in which record inserted,rowid,which rowid is inserted ,and which user inserted or deleted... the record and in inseted table historyrowid and table row_id columns should also be update after inserting....i searched alot but i dint get any good result..will you plzzz tell me the proper logic..to solve this task...i used 1 logic,in dal layer after inserting recordd in table i am excuteitng 1 more insert statement for insert records in log table,but i think its not correct logic..plzz suggest me with proper logic.....
Loading
mohit mahajanPosted Mar 23, 2012, 12:35 PM
the thing is i am not able to reterive the tablerowid or table name in log_history_table means(from which table the row is inserted or updated or deleted),i need username of application so i did hard coded in my dataaccess layer of asp.net,first m executing insert query for which data is inserted and at atlast m using identy_colmn to reteive the last row inserted id..
then again m executing insert query for log_history table where i mention above i need to insert(tablerowid or u can say table name,rowid(which row is inserted) user_id(application_user name),operation(insert,update).
while insertind in log_table m gettion rowid,username, operations(for opration m adding manully string for insert ,update),but m not getting tablename in which table the record is inserted...
wht i did,in master_table from where i will get the tablerow_id or table_name.i inserted tablerowid,tablename manully and while inserting in log history table in tablerowid column i added the values of tablerowid that exists in master_tables manually.like this
Eg: insert into log_historytable(tablerowid,rowid,user_id,operations) values(1,rowid(from identitycolumn),session[userid].value.tostring(),'insert');
please teme how can i get the tablename without adding manually in log history table.in log history_table tablerowid is foreign key of master_tables table..plzz give me sum live exanple or write send some code so that i can do this.
thanks in advance sir
Suthish NairPosted Mar 23, 2012, 10:59 AM