- cannot manually edit applicationhost.config
- must declare the scalar variable
- classic asp and access not working on windows 2008 64bit
- asp.net page titles are blank
- sql to get totals for last six months
- white space being counted as a node
- cross page posting not working
- collection is read only exception
- PayPal sending incorrect carrier information
- paypal guest user notice
- classic asp dictionary not working
- IE8 not supporting innerHTML
- differences between jet and odbc
- sugarcrm not inserting email
- select random records from access
- button click event firing twice
- how to send an email using cdosys
- installing perl on win2003 64 bit
- asp.net page event order
- rewrite rule for subdomains only
- extra items in javascript array
- IE7 margin auto not working
- IE7 border style dotted glitch
- ByRef and ByVal in vbscript
- weather rss feed
- Classic asp crib sheet
- Firefox onsubmit image change
- limit records in access
- AccessDataSource is thick
- double margins in IE6
- extra image padding in html emails
- decimal places in linux flash player
- broken emails in outlook 2007
- double spaced IE list items
- cannot remove movieclip
articles:
AccessDataSource is thick
Well it might not be thick, but its certainly not that intuitive for someone who has previously enjoyed the freedom of writing their own queries in good old classic asp or executing nonqueries in asp.net.
Here is why i have been bashing my head against a wall for the last couple of hours:
<asp:AccessDataSource ID="AccessDataSource3" runat="server"
DataFile="~/App_Data/database.mdb"
UpdateCommand="UPDATE [table1] SET [field1]= @field1 WHERE [ID] = @ID"
SelectCommand="SELECT [ID], [field1], [field2] FROM [table1] WHERE ([ID] = ?)">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="ID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:AccessDataSource>
So what was I doing? Very simple: a grid view allows a user to select a record, that record is then displayed in a form view. The form view is using the AccessDataSource shown above. The form views default mode is set to edit.
So whats all the fuss about?
When you press update it doesn't. Thats what the fuss is about. Having rewritten all the relevant bits a couple of times and it still not working, i decided to try and isolate the problem. The first thing i tried was to hardcode the ID being used by the WHERE in the UPDATE statement.
Ah ha! some success, hard coding the ID worked, but of course now my fantastic grid view form view combo could only update on record.
Just out of interest i changed SET [field1]= @field1 -> SET [field1]= @ID
How strange - i was getting the field1 written instead of the ID; so the reason it wouldn't update before was because field1 was being sent for both the field1 value and the ID value.
I guessed that this sort of thing was going to happen when there weren't enough parameters being sent. I noticed that he selectCommand was retrieving field1 and field2 and the updateCommand was only updating field1.
In good old classic asp you can update what ever you like and select whatever you like no problem. But not apparently with the AccessDataSource; you have to update whatever you select. So the correct code should be:
SelectCommand="SELECT [ID], [field1], [field2] FROM [table1] WHERE ([ID] = ?)"
UpdateCommand="UPDATE [table1] SET [field1]= @field1, [field2] = @field2 WHERE [ID] = @ID"
And now everything works. But thats still Classic ASP 1 - 0 ASP.NET (of course generating the gridview that allows for the population of the formview only took about 5 mins, so i guess they are even)
Here is why i have been bashing my head against a wall for the last couple of hours:
DataFile="~/App_Data/database.mdb"
UpdateCommand="UPDATE [table1] SET [field1]= @field1 WHERE [ID] = @ID"
SelectCommand="SELECT [ID], [field1], [field2] FROM [table1] WHERE ([ID] = ?)">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="ID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:AccessDataSource>
So what was I doing? Very simple: a grid view allows a user to select a record, that record is then displayed in a form view. The form view is using the AccessDataSource shown above. The form views default mode is set to edit.
So whats all the fuss about?
When you press update it doesn't. Thats what the fuss is about. Having rewritten all the relevant bits a couple of times and it still not working, i decided to try and isolate the problem. The first thing i tried was to hardcode the ID being used by the WHERE in the UPDATE statement.
Ah ha! some success, hard coding the ID worked, but of course now my fantastic grid view form view combo could only update on record.
Just out of interest i changed SET [field1]= @field1 -> SET [field1]= @ID
How strange - i was getting the field1 written instead of the ID; so the reason it wouldn't update before was because field1 was being sent for both the field1 value and the ID value.
I guessed that this sort of thing was going to happen when there weren't enough parameters being sent. I noticed that he selectCommand was retrieving field1 and field2 and the updateCommand was only updating field1.
In good old classic asp you can update what ever you like and select whatever you like no problem. But not apparently with the AccessDataSource; you have to update whatever you select. So the correct code should be:
SelectCommand="SELECT [ID], [field1], [field2] FROM [table1] WHERE ([ID] = ?)"
UpdateCommand="UPDATE [table1] SET [field1]= @field1, [field2] = @field2 WHERE [ID] = @ID"
And now everything works. But thats still Classic ASP 1 - 0 ASP.NET (of course generating the gridview that allows for the population of the formview only took about 5 mins, so i guess they are even)
Post a comment
