以下のようなページを作成しました。
<table>
<tr>
<td align="right"> Collection Area</td>
<td> :</td>
<td align="left">
<asp:CheckBoxList ID="ChkCollAreaNewFile" runat="server">
<asp:ListItem Value="Retail Banking Division">Retail Banking Division</asp:ListItem>
<asp:ListItem Value="Chittagong Zone">Chittagong Zone</asp:ListItem>
<asp:ListItem Value="Khulna">Khulna</asp:ListItem>
<asp:ListItem Value="Sylhet">Sylhet</asp:ListItem>
<asp:ListItem Value="Rajshahi">Rajshahi</asp:ListItem>
<asp:ListItem Value="Barisal">Barisal</asp:ListItem>
</asp:CheckBoxList>
</td>
<td align="right"> Disbursed Area</td>
<td> </td>
<td align="left" style="margin-left: 40px">
<asp:CheckBoxList ID="ChkDisbAreaNewFile" runat="server"
DataSourceID="DSDisbAreaNewFile" DataTextField="RegionName"
DataValueField="RegionName">
</asp:CheckBoxList>
<asp:SqlDataSource ID="DSDisbAreaNewFile" runat="server"
ConnectionString="<%$ ConnectionStrings:OptimaWebCustomerQueryCon %>"
SelectCommand="SELECT [RegionName] FROM [DDRegion]"></asp:SqlDataSource>
</td>
<td> </td>
</tr>
<tr>
<td align="right"> Loan Type</td>
<td> :</td>
<td align="left">
<asp:DropDownList ID="DDLLoanTypeNewFile" runat="server" AppendDataBoundItems="true"
DataSourceID="DSAssignCELoanType" DataTextField="LType" DataValueField="LType">
<asp:ListItem Value="%">-Select-</asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="DSAssignCELoanType" runat="server"
ConnectionString="<%$ ConnectionStrings:OptimaWebCustomerQueryCon %>"
SelectCommand="SELECT [LType] FROM [DDLoanType] ORDER BY [LType]">
</asp:SqlDataSource>
</td>
<td align="right"> Cycle</td>
<td> :</td>
<td align="left">
<asp:DropDownList ID="DDLCycleNewFile" runat="server">
<asp:ListItem Value="">-Select-</asp:ListItem>
<asp:ListItem Value="X">X</asp:ListItem>
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5">5</asp:ListItem>
<asp:ListItem Value="6">6</asp:ListItem>
<asp:ListItem Value="7">7</asp:ListItem>
</asp:DropDownList>
</td>
<td> </td>
</tr>
<tr>
<td align="right"> </td>
<td> </td>
<td align="left">
<asp:Label ID="lblMsBx" runat="server" Text="Label"></asp:Label>
</td>
<td align="right">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
<td> </td>
<td align="right" style="margin-left: 40px">
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="btnRankUpdate" runat="server" Text="Update"
onclick="btnRankUpdate_Click"/>
</td>
<td> </td>
</tr>
<tr>
<td align="right"> </td>
<td> </td>
<td align="left">
</td>
<td align="right"> </td>
<td> </td>
<td align="right" style="margin-left: 40px">
</td>
<td> </td>
</tr>
</table>
ボタンを押すと、ストアド プロシージャが実行され、レコードが更新されます。以下のように私のストアドプロシージャ:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[WebRecNewFileAssign]
@ParmAppLoanType varchar(100),
@ParmBRegion varchar(1000), --Disbursed Area
@ParmUserBrDiv varchar(1000), -- Collection Area
@AssingCycle varchar(100)
as
begin
DECLARE db_cursor CURSOR FOR
SELECT dbo.TblDisburseInfo.DisbID FROM dbo.TblDisburseInfo INNER JOIN
dbo.TblMasterInfo ON dbo.TblDisburseInfo.DisbAppID = dbo.TblMasterInfo.AppID
WHERE (dbo.TblDisburseInfo.DisbRecAssignTo IS NULL) AND (dbo.TblMasterInfo.AppLoanType = @ParmAppLoanType) AND
(dbo.TblDisburseInfo.DisbBr in(SELECT BrName FROM DDBranchName Where BRegion in(@ParmBRegion) ))
ORDER BY dbo.TblDisburseInfo.DisbAmt DESC
declare @tdisbid as int
declare @cnt as int
set @cnt = 1
declare @maxcnt as int
select @maxcnt = MAX(reid) from [dbo].[TblRecAssignName] WHERE ReAssignName in (SELECT LogId FROM TblUserTest
where UserBrDiv in(@ParmUserBrDiv) AND ReCycle=@AssingCycle)
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @tdisbid
WHILE @@FETCH_STATUS = 0
BEGIN
update [OptimaUCBL].[dbo].[TblDisburseInfo]
set DisbRecAssignTo = (select ReAssignName from [OptimaUCBL].[dbo].[TblRecAssignName]
where [ReID] = @cnt AND ReAssignName in (SELECT LogId FROM TblUserTest
where UserBrDiv in (@ParmUserBrDiv) AND ReCycle=@AssingCycle))
where [DisbID] = @tdisbid
if @cnt = @maxcnt
set @cnt = 1
else
set @cnt = @cnt + 1
FETCH NEXT FROM db_cursor INTO @tdisbid
END
CLOSE db_cursor
DEALLOCATE db_cursor
end
最後に私のコード(C#)::
protected void btnRankUpdate_Click(object sender, EventArgs e)
{
string myDisbArea = "";
for (int i = 0; i < ChkDisbAreaNewFile.Items.Count; i++)
{
if (ChkDisbAreaNewFile.Items[i].Selected)
{
myDisbArea = myDisbArea + "'" + ChkDisbAreaNewFile.Items[i].Value + "' ,";
}
}
string NewDisbAreaNewFile = myDisbArea.Substring(myDisbArea.Length - (myDisbArea.Length), (myDisbArea.Length - 1));
string AreaSelected = "";
for (int i = 0; i < ChkCollAreaNewFile.Items.Count; i++)
{
if (ChkCollAreaNewFile.Items[i].Selected)
{
AreaSelected = AreaSelected + "'" + ChkCollAreaNewFile.Items[i].Value + "' ,";
}
}
string NewAreaSelected = AreaSelected.Substring(AreaSelected.Length - (AreaSelected.Length), (AreaSelected.Length - 1));
String strConnString = ConfigurationManager.ConnectionStrings["OptimaWebCustomerQueryCon"].ConnectionString;
SqlConnection con = new SqlConnection(strConnString);
SqlCommand com = new SqlCommand();
com.CommandType = CommandType.StoredProcedure;
com.CommandText = "WebRecNewFileAssign";
com.Parameters.AddWithValue("@ParmAppLoanType", SqlDbType.VarChar).Value = DDLLoanTypeNewFile.SelectedValue;
com.Parameters.AddWithValue("@ParmBRegion", SqlDbType.VarChar).Value = Convert.ToString(NewDisbAreaNewFile);
com.Parameters.AddWithValue("@ParmUserBrDiv", SqlDbType.VarChar).Value = Convert.ToString(NewAreaSelected);
com.Parameters.AddWithValue("@AssingCycle", SqlDbType.VarChar).Value = DDLCycleNewFile.SelectedValue;
com.Connection = con;
try
{
con.Open();
com.ExecuteNonQuery();
lblMsBx.Text = "Record updated successfully";
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
con.Dispose();
}
}
更新ボタンを押すとRecord updated successfully
メッセージが表示されますが、レコードは更新されません。私の問題はどこにあるのか、特定できません。Pls は私をサポートします。
ありがとう