我开发了一个如下页面:
<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
消息显示但记录没有更新。我的问题在哪里,我无法确定。请支持我。
谢谢