asp.net - APS.NET Registration problems when inserting to 2 tables in SQL Server database -
i pretty new asp.net , sql server please provide support detail possible, appreciate it. here situation:
i doing registration system website using aps.net , sql server 2012 express.
so when user registering, first of all, need fill out account information (name, address, phone, email, password...) , secondly, need fill company information - working @ (company name, company industry, website, description...). in database have 2 table: user , company
problem when filled out require fields in registration form , click submit button, how check if data has been inserted 2 tables successfully, because if reason after data inserted user table failed company table gonna problem, don't know if there way check or reverse process in sql server if inserting query failed.
i don't know make sense of you, please ask me if don't understand question.
thank you!
without code hard answer.
in .net can use try{} catch{}
blocks handle errors , act upon them.
a better approach commit user , company in 1 transaction. dependent on data access approach. in linq2sql need have 2 insertions in 1 submitchanges() example. or transactionscope
http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx
update: read remarks in link:
the system.transactions infrastructure provides both explicit programming model based on transaction class, implicit programming model using transactionscope class, in transactions automatically managed infrastructure.
Comments
Post a Comment