Fixing the "No value given for one or more parameters" in Visual Web Developer 2008

This error normally appears when you have selected enable deleting and enable editing GridView or FormView task options and you try to delete or update a record at run-time. This error can be fixed by converting the SQL statements in the InsertCommand and AccessCommand to Jet SQL statements. To be able to clearly understand the solution, let us start from the beginning:
1. Create a database file in Ms-Access and name it “dbNames”. Make a table inside it and name it “tblEmployee” using the following specification:

2. Don’t forget to click yes when you will be ask to create primary key, otherwise you will not be able to add an Edit or Delete buttons to your grid view control.
3. Add appropriate values to your table, for instance:

4. Click Start>All Programs>Visual Web Developer 2008.
5. Click File>New Website>ASP.net Website>Ok.
6. Click View>Solution Explorer>Right-click your website solution name, Select Add Existing Item. Locate you dbnames access database file>Add. The solution explorer should now look like this.

7. Click the design tab then add a GridView control to your form.
8. In the Choose data source listbox, select new data source>Select Access database>Click the browse button>Select dbnames>Ok>Next>Click the * checkbox from the columns category>Click the advance button>Click the Generate Insert, Update, and Delete statements checkbox including the Use Optimistic Concurrency checkbox>Ok.
9. Click Next. Click test query to view the result of the sql statement then click finish.
10. Click the GridView task button(>) then check enable paging, enable sorting, enable editing, enable deleting, and enable selection checkboxes.
11. Click the View in Browser button. If you are prompted to save changes to your website, just click the yes button.
12. If you try to click or update a record value now, you will be taken to the following to a screen containing the following message:

13. To solve this problem, click the Source tab to view the source code of your website. Look for the following lines:

14. Delete the OR logical operators including its respective conditions, your code should now look like this:


15. Click the View Browser button and try clicking the Deleting or Record value. This time you can delete or delete a record value without getting a ““No value given for one or more required parameters”

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.