1. To create a connection to the sql database, we need to write code to button click procedure, and have the database setup with stored procedures for accessing and modifying data in it.
2. In the that procedure, we establish a connection to the database, point to where and how to authenticate with the database when the button is click.
3. Setup what each corresponding textbox value to the proper column in the database. Then open up the connection, execute the query that you want to do, and then close the connection. (as seen below of what the code could look like)

Once the code is written, you are ready to test your code that connects the web form to the database. There are a couple of way that you can debug your code if it does not work. One way is putting a break point in your connection code to see if there is a problem, using the profiler in sql server is another way that you can see if any programs are access the database.
For the debugger in Visual Studios.
1. Place a break point in your button click towards to the top to see how far you can go down the lines of code.
2. Open the up that web form page and click on the button to start the debugger.
3. Use F11 to walk through your code line by line as shown below.

For using the profiler in SQL Server.
1. Open up SQL Server Management Studio.
2. Go to the Tools menu and select SQL Server Profiler from the menu.
3. Create a new trace to have the database watches for applications that connect to the database and show details about it.
4. Select which database you want to watch.
5. Then the trace properties box opens up to setup what you want to watch.

6. You may want to go to Events Selection tab to filter out report server.
7. Run your trace and see if your web form is connecting to correct database.

8. Here in the trace program you can see what stored procedure was used, and what the values were that were written into the database rows.
No comments:
Post a Comment