开发者

ASP.Net & SQL Server backend debugging interview question

开发者 https://www.devze.com 2023-03-19 09:18 出处:网络
I got this in an interview question. You have an asp.net page, with a sql backend. You run the asp page, the form comes up, you enter the data in the fields. click submit and the page comes back with

I got this in an interview question.

You have an asp.net page, with a sql backend. You run the asp page, the form comes up, you enter the data in the fields. click submit and the page comes back with no errors / exceptions thrown.

You look in the database table, and there are no values entered 开发者_如何学Cin the appropriate tables.

How would you debug this issue?


There are tons of ways to approach debugging this issue. A few that come to mind would be using a profiler. SqlServer has a profiling tool that allows you to see all transactions being executed against the database. I would imagine most other commercial databases have something similar.

You're using asp.net, so I would assume Visual Studio is available which has rich debugging tools to test your Data Access logic.

My procedure would first be to debug my code and ensure there are no logical errors. I'd probably look at the method that is calling the stored procedure that inserts data into the database and insure the data being mapped to the parameters of the procedure is correct. I would then execute the procedure and ensure there were no exceptions being "swallowed" in my code. If this passes I would be confident that it's a problem with the database and I would move on to profiling/reviewing the logic of my stored procedure, including debugging the procedure with the value being sent to the proc from the code.

Hope this helps.


Using Visual Studio, set a breakpoint slightly before the code that submits the request to the DB. Start the site in debug mode (easy if you can use Cassini; otherwise attach the debugger to the running IIS process). When the breakpoint hits, single-step and make sure that the submitted parameters are as expected.

If everything looks OK there, then use SQL Profiler to see the exact command that's being sent to the DB. If it looks correct, copy-and-paste the T-SQL from SQL Profiler into Management Studio and see if it behaves correctly from there. If it works as expected in Management Studio but not in your app, consider possible permissions issues for the associated SQL Server user / identity.

0

精彩评论

暂无评论...
验证码 换一张
取 消