- 追加された行はこの色です。
- 削除された行はこの色です。
#freeze
閲覧総計:&counter(); (本日:&counter(today); 昨日:&counter(yesterday);)
ListViewでAccessデータを「編集」する際、「オプティミスティック同時実行制御」
を設定すると編集決定時の「更新」ボタンを押した際、「1 つ以上の必要なパラメー
タの値が設定されていません。 」のエラーが発生し動かなくなります。
この問題の解決方法を備忘目的で記載しておきます。(3.5) 09/09/13
※ListViewでAccessデータを「編集」する際、「オプトミスティック同時実行制御」
を設定しなければ、問題なく「編集」機能が動作します。
【原因】
自動生成されたUpdateCommandの「?」の数は7つなのに対して、自動生成された
Parameter行がは5行と2行不足している事が原因。
UpdateCommand="UPDATE [名簿] SET [名前] = ?, [年齢] = ? WHERE [ID] = ? AND (([名前] = ?) OR ([名前] IS NULL AND ? IS NULL)) AND (([年齢] = ?) OR ([年齢] IS NULL AND ? IS NULL))"
<UpdateParameters>
<asp:Parameter Name="名前" Type="String" />
<asp:Parameter Name="年齢" Type="Int16" />
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_名前" Type="String" />
<asp:Parameter Name="original_年齢" Type="Int16" />
</UpdateParameters>
【解決方法】
自動生成されたUpdateCommandの「?」の数に合わせて、Parameter行
<asp:Parameter Name="original_名前" Type="String" />
<asp:Parameter Name="original_年齢" Type="Int16" />
の2行を追加してやる。
<UpdateParameters>
<asp:Parameter Name="名前" Type="String" />
<asp:Parameter Name="年齢" Type="Int16" />
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_名前" Type="String" />
&color(crimson){<asp:Parameter Name="original_名前" Type="String" />};
<asp:Parameter Name="original_年齢" Type="Int16" />
&color(crimson){<asp:Parameter Name="original_年齢" Type="Int16" />};
</UpdateParameters>
Accessデータベース名:MyDB.mdb
テーブル名:名簿
|~フィールド名|~データ型|~フィールドサイズ|
|ID (主キー)|オートナンバー型|長整数型|
|名前|テキスト型|50|
|年齢|数値型|整数型|
※ASP.NET3.5ではAccess2007のDBファイル形式(*.accdb)は利用できない模様。
DBファイルは「Acces2002-2003形式(*.mdb)」で保存してASP.NET3.5で利用する。
開発環境:VWD2008
サーバ:Windows Server2003 + .NET Framework3.5
【機能】ListViewの「編集」ボタンでAccessデータを編集する。
【稼働画面】
#ref(ListViewEditOpt.JPG);
「編集」機能が正しく動く様になった自動生成全コード
【ListViewEditOpt.aspx】[3.5]
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
ListViewでのAccessデータの編集機能の確認 09/09/13<br />
(ID:オートナンバー型、同時実行制御)<br />
<br />
<asp:ListView ID="ListView1" runat="server" DataKeyNames="ID"
DataSourceID="AccessDataSource1">
<ItemTemplate>
<tr style="">
<td>
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="編集" />
</td>
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:Label ID="名前Label" runat="server" Text='<%# Eval("名前") %>' />
</td>
<td>
<asp:Label ID="年齢Label" runat="server" Text='<%# Eval("年齢") %>' />
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="">
<td>
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="編集" />
</td>
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:Label ID="名前Label" runat="server" Text='<%# Eval("名前") %>' />
</td>
<td>
<asp:Label ID="年齢Label" runat="server" Text='<%# Eval("年齢") %>' />
</td>
</tr>
</AlternatingItemTemplate>
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>
データは返されませんでした。</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="挿入" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="クリア" />
</td>
<td>
</td>
<td>
<asp:TextBox ID="名前TextBox" runat="server" Text='<%# Bind("名前") %>' />
</td>
<td>
<asp:TextBox ID="年齢TextBox" runat="server" Text='<%# Bind("年齢") %>' />
</td>
</tr>
</InsertItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="0" style="">
<tr runat="server" style="">
<th runat="server">
</th>
<th runat="server">
ID</th>
<th runat="server">
名前</th>
<th runat="server">
年齢</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="">
</td>
</tr>
</table>
</LayoutTemplate>
<EditItemTemplate>
<tr style="">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="更新" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="キャンセル" />
</td>
<td>
<asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:TextBox ID="名前TextBox" runat="server" Text='<%# Bind("名前") %>' />
</td>
<td>
<asp:TextBox ID="年齢TextBox" runat="server" Text='<%# Bind("年齢") %>' />
</td>
</tr>
</EditItemTemplate>
<SelectedItemTemplate>
<tr style="">
<td>
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="編集" />
</td>
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:Label ID="名前Label" runat="server" Text='<%# Eval("名前") %>' />
</td>
<td>
<asp:Label ID="年齢Label" runat="server" Text='<%# Eval("年齢") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
ConflictDetection="CompareAllValues" DataFile="~/App_Data/MyDB.mdb"
DeleteCommand="DELETE FROM [名簿] WHERE [ID] = ? AND (([名前] = ?) OR ([名前] IS NULL AND ? IS NULL)) AND (([年齢] = ?) OR ([年齢] IS NULL AND ? IS NULL))"
InsertCommand="INSERT INTO [名簿] ([ID], [名前], [年齢]) VALUES (?, ?, ?)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT [ID], [名前], [年齢] FROM [名簿]"
UpdateCommand="UPDATE [名簿] SET [名前] = ?, [年齢] = ? WHERE [ID] = ? AND (([名前] = ?) OR ([名前] IS NULL AND ? IS NULL)) AND (([年齢] = ?) OR ([年齢] IS NULL AND ? IS NULL))">
<DeleteParameters>
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_名前" Type="String" />
<asp:Parameter Name="original_年齢" Type="Int16" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="名前" Type="String" />
<asp:Parameter Name="年齢" Type="Int16" />
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_名前" Type="String" />
<asp:Parameter Name="original_名前" Type="String" />
<asp:Parameter Name="original_年齢" Type="Int16" />
<asp:Parameter Name="original_年齢" Type="Int16" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="名前" Type="String" />
<asp:Parameter Name="年齢" Type="Int16" />
</InsertParameters>
</asp:AccessDataSource>
</div>
</form>
</body>
</html>
【参考にしたページ】
該当なし
- http://www.coachcanadaoutlet.ca http://www.prada-outlet.us http://www.louboutinfemme-pascher.fr http://www.ralphlaurensale.eu.com http://www.jordan3.net http://www.louisvuitton-handbags.com.co http://www.poloralphlaurenhome.net http://www.abercrombie.net.co http://www.holister.name http://www.christian-louboutinoutlet.org http://www.rolexwatchesoutlet.us http://www.abercrombieandfitch.net.co http://www.coachoutletstoreonline.us.org http://www.katespade-outlet.us.com http://www.chanelhandbags.in.net http://www.longchamp-outlet.name http://www.jordan4.net http://www.raybans.name http://www.michaelkorsoutletus.eu.com http://www.louisvuittonoutlets.name http://www.airmax-nike.me.uk http://www.hollisterinc.name http://www.cheaptoms.us http://www.fendi.us.com http://www.michaelkorsoutlet-mk.eu.com http://www.hollister-clothing.net http://www.juicy-couture.us http://www.hollisterclothing.us http://www.pandorajewelry.net.co http://timberlandboots.hugeoff.net http://www.hollisterkids.net http://www.abercrombiestores.net http://www.louisvuittonoutlet-inc.us http://oakley.hugeoff.net http://www.ralph-lauren.net.co http://www.louis-vuitton.us.org http://www.louis--vuitton.us http://lululemon.suleymanaltun.com http://www.marc--jacobs.com http://www.airjordan-pascher.fr http://www.abercrombie.in.net http://www.louisvuitton-lvoutlet.me http://www.guccishoes.us.com http://www.coachoutlet.net.so http://www.michaelkorshandbags.com.so http://www.tory-burchoutlet.in.net http://www.rayban-sunglasses.com.co http://www.retrojordans.name http://www.concords11.com http://www.cheapjordansshoes.in.net http://www.p90xworkouts.us http://truereligion.officialbid.net http://www.guccioutlet.net.co http://burberry.stores.net.co http://www.michaelkorshandbags.eu.com http://www.edhardyclothing.in.net http://www.michaelkorsoutletonlinee.in.net http://www.chiflatiron.com.co http://www.oakleysunglassessale.in.net http://burberryoutlet.officialstore.com.co http://www.coachoutletstoreonline.eu.com http://www.gucci.net.co http://www.abercrombieandfitch.cc http://www.coach-outlet.us.com http://www.michaelkorsoutlet.net.so http://www.cocochaneluk.co.uk http://www.louisvuitton-outlet.us.com http://www.louisvuittonhandbags.net.co http://www.ralph-lauren-outlet.co http://www.louisvuittonuk.me.uk http://www.coach-outlet.us.org http://www.ray-bansunglasses.name http://www.louis-vuitton.net.co http://www.adidasshoes.name http://www.louis-vuittonoutlet.us.org http://www.true-religion-outlet.us.com http://www.michaelkorsonlineoutlet.in.net http://www.jordan13.org http://www.abercrombieoutlet.name http://www.kobeshoes.org http://www.hollister-co.net http://www.holisterclothingstore.com http://www.michaelkorsoutlet.com.so http://www.fitflops.org http://www.kobebryantshoes.name http://www.oakley-sunglasses.net.co http://www.kevindurantshoes.name http://www.pradauk.co.uk http://www.michaelkorsukpurse.co.uk http://www.gucci-outlet.org http://burberry.bidinc.org http://www.oakleysunglassescheap.name http://www.oakleysunglasses.us.com http://michaelkors.officialstore.com.co http://www.cheapsoccershoes.in.net http://www.coachoutlet-storeonline.in.net http://www.todsshoes.us http://www.jordan8.net http://www.christianlouboutinoutlet.org http://www.raybanglasses.me.uk http://www.abercrombieoutlet.us.com http://www.montblanc-pens.name http://www.christianlouboutin.name http://www.oakleysunglasses-wholesale.name http://www.raybansunglassesoutlet.name http://www.christianlouboutin-shoes.info http://www.raybansunglass.net.co http://www.ray-banoutlet.name http://www.michaelkors--outlet.in.net http://www.truereligion.eu.com http://www.coach-factoryoutlet.com.co http://www.outlet-celine.com http://www.christianlouboutinoutlet.com.co http://www.oakleysunglasses-outlet.name http://www.fitflop-shoes.us http://www.soccer-jerseys.us.com http://www.michaelkors.com.so http://www.todsoutlet.name http://www.cheap--nfljerseys.us.com http://www.abercrombie-fitch.cc http://www.tory-burch-outlet.name http://www.redchristianlouboutin.com http://www.hermes-birkin.us http://www.michaelkors-mkoutlet.in.net http://timberland.officialfree.net http://www.chanel-handbags.net.co http://www.christianlouboutinsale.name http://www.jordan11s.name http://www.pandorajewelry.name http://burberryoutlet.newestsite.net http://www.louisvuitton.us.com http://www.montblanc.com.co http://www.cheap-jordans.us.com http://www.toms--shoes.com http://beatsbydrdre.outletoff.net http://www.cheapjerseys-wholesale.us.com http://www.christianlouboutinsale.biz http://www.michael-korsoutletonline.eu.com http://www.abercrombiestore.org http://www.rayban-sunglasses.eu.com http://www.louis-vuittonhandbags.name http://www.oakley-sunglasses.com.co http://timberlandboots.dealsinc.net http://www.nike-airmax.me.uk http://www.jordan11.name http://www.saclongchamp--pascher.fr http://www.michaelkors-outlet.com.co http://www.gucci-outlet.name http://michaelkors.aphidsymposium.org http://www.cheaprolexwatches.name http://www.chanelbags.com.co http://www.toms-shoes.cc http://www.insanityworkout.com.co http://www.louisvuittonoutlet.net.co http://www.coachfactoryoutlet.com.so http://www.jordanretro.name http://coachoutlet.officialinc.net http://www.toms-outlet.com.co http://www.poloralph-lauren.net.co http://toryburchoutlet.stores.net.co http://www.michaelkorsbag.org.uk http://www.coachoutlet-factory.com.co http://www.dior-handbags.us http://chanelhandbags.newstore.com.co http://www.abercrombiekids.name http://www.coachfactoryoutletonline.eu.com http://www.jordan11concord.org http://www.abercrombie-fitch.com.co http://www.michaelkorsoutletclearance.in.net http://www.jordanconcords.net http://www.gucci-outlet.net.co http://www.lebronjames-shoes.net http://www.adidaswings.name http://www.celine-outlet.us http://www.hollisterclothing.info http://www.ghdhairstraighteners.com.co http://www.lebronjames-shoes.name http://www.oakleysunglasses-sale.in.net http://www.longchamphandbags.com.co http://truereligion.onlineinc.net.co http://www.hollisteroutlet.name http://www.katespade-handbags.eu.com http://www.ray-ban-sunglasses.org.uk http://www.jordan6.net -- [[2015711yuanyuan]] &new{2015-07-10 (金) 22:00:37};
#comment_nospam
#vote(参考になった[1],ふつう[0],参考にならなかった[0])