Last post Mar 30, 2011 04:03 AM by dalebh
Mar 23, 2011 09:38 AM|dalebh|LINK
Im using Visual Web Developer 2010 Express and have put together a custom form using ASP controls and labels.
I now need to update an access database with the data that is captured on the form. I have added an AccessDataSource but do not know how to link the fileds to the fileds within the database so that when I click submit it updates the table.
Mar 23, 2011 10:02 AM|gopalanmani|LINK
check the following urls,
Mar 26, 2011 10:17 PM|Decker Dong - MSFT|LINK
1) You should first have a public property that can let you get or set the value from your costomized control to connect with the web form.
2) Then your AccessDataSource should have a update statement with some parameters, and you can set dynamically, something looks like this：
……UpdateCommand="Update [Detail] Set [sBank] = ? , [dDate] = ? , [Type] = ? , [Class] = ? , [iMoney] = ? , [remark] = ? Where [Id] = ?"
<asp:Parameter Name="sBank" Type="String" />
<asp:Parameter Name="dDate" />
<asp:Parameter Name="Type" Type="string" />
<asp:Parameter Name="Class" Type="string" />
<asp:Parameter Name="iMoney" />
<asp:Parameter Name="Remark" Type="string" />
<asp:Parameter Name="Id" Type="int32" />
Then in the button, do this:
AccessDataSource1.UpdataParameters["sBank"].DefaultValue = CusomizedControl.sBank;
AccessDataSource1.UpdataParameters["dDate"].DefaultValue = CusomizedControl.dDate;
AccessDataSource1.UpdataParameters["Id"].DefaultValue = CusomizedControl.Id;
Mar 28, 2011 02:14 AM|dalebh|LINK
Thanks for the responses but I need to know if there is a way to configure this in Visual Web Developer using the built in tools and wizards?
Mar 28, 2011 03:19 AM|Decker Dong - MSFT|LINK
Of course I think you can do that with flexible VS Studio：）
Just Drag and drop a AccessDataSource and do as the followings：
Mar 28, 2011 05:05 AM|hans_v|LINK
Decker Dong - MSFT
Not really, because the Wizards are not optimised for using Access.
Mar 28, 2011 10:40 AM|dalebh|LINK
Okay. Maybe im not explaining myself properly.
I have an input form which I created by dragging and dropping controls onto the page. I then need to update the database table "Customer Service" (An access database) with the data from the form.
Now, What I need to understand is how to set this up using an accessdatasource.
How do you link the controls on the form to the fields in the database? Does the accessdatasource support this or do I need to write code where I declare variables, use the request.form string to pull the data from the form and use ADO to connect and write
the values to the database?
Mar 28, 2011 09:48 PM|Decker Dong - MSFT|LINK
It seems that you want to link the DataSource to your other controls on the same page and do something like filtering…… Some other things?
If really, I think you can use ControlParameter with the wizard.
Here's something like what you need, correct me if I'm wrong：）
1) Please click the right small arrow and choose AccessDataSource：
2) And then there appears a dialog to let you select columns to be shown in the GridView, you should choose several fields to be shown in the AccGridView or any data presentation control,and then click "Where“：
3）Then you can see a dialog poping up like this, and you can choose a column to filter data with, and "Source" should choose Form.
Then you should give the Form name and default value in the "Parameter properties". And click "Add" button.
Mar 30, 2011 04:03 AM|dalebh|LINK
Thanks for the replies. To save myself a whole lot of trouble, I ended up using the formview control in VWD. Its much easier as you set up your data source (In this case an AccessDataSource), specify that you want it to be able to insert, update and delete
and bind the controls to the datasource while editing the built in templates.
Thanks again for all the help!