.cs代码
protected void Button2_Click(object sender, EventArgs e)
{
try
{
this.shopnum = Convert.ToInt32(this.Text_num.Text.Trim().ToString());
}
catch (Exception)
{
ChangeHope_fc.Show_Msg("商品发布量数量格式不正确");
}
int num = 0;
int num2 = 0;
int num3 = 0;
int num4 = 0;
int num5 = 0;
int num6 = 0;
string str = "";
StringBuilder builder = new StringBuilder();
if (this.RadioButton1.Checked)
{
num = 1;
}
if (this.RadioButton3.Checked)
{
num2 = 1;
}
if (this.RadioButton5.Checked)
{
num3 = 1;
}
if (this.RadioButton11.Checked)
{
num6 = 1;
}
str = "";
this.Exsql.Open();
builder.Append(string.Concat(new object[] { "Update YX_UserParameter Set YX_UserReg=", num, ",YX_UserVer=", num2, ",YX_SenderEmail=", num3, "," }));
builder.Append(string.Concat(new object[] { "YX_EmailConfir=", num4, ",YX_StrFilters='", str, "',YX_TJUser=", num5, ",YX_RetPwd=", num6, ",YX_ShopTime=", this.DropDownList1.SelectedValue, ",YX_Userfw=@YX_Userfw,YX_UserZFB=@YX_UserZFB where YX_ID=1" }));
SqlCommand command = new SqlCommand(builder.ToString(), this.Exsql.con);
command.Parameters.Add(new SqlParameter("@YX_Userfw", SqlDbType.Text));
command.Parameters["@YX_Userfw"].Value = this.TextBox14.Text;
command.Parameters.Add(new SqlParameter("@YX_UserZFB", SqlDbType.Text));
command.Parameters["@YX_UserZFB"].Value = this.TextBox15.Text;
command.ExecuteNonQuery();
command.Dispose();
this.sqlstr = "alter table YX_UserInfo drop constraint DF_YX_UserInfo_YX_Num";
this.Exsql.YX_ExecSql(this.sqlstr);
this.sqlstr = "alter table YX_UserInfo add constraint DF_YX_UserInfo_YX_Num default (" + this.shopnum + ") for yx_num";
this.Exsql.YX_ExecSql(this.sqlstr);
this.sqlstr = "update YX_UserInfo set yx_num=" + this.shopnum + "";
this.Exsql.YX_ExecSql(this.sqlstr);
ChangeHope_fc.Show_Msg("操作成功!", "YX_SystemWeb.aspx?YX_FS=User");
}
.aspx代码
<asp:Panel ID="Panel2" runat="server" Width="100%"> <table align="center" cellpadding="4" cellspacing="1" border="1" width="100%" class="toptable grid">
<tr>
<td height="25" class="category t2" width="100px">系统基本设置</td><td class="category">
<a href="?"> [网站基本设置]</a>
<a href="?YX_FS=User"> [网站会员参数设置]</a>
</td>
</tr>
</table>
<table align="center" cellpadding="1" cellspacing="1" border="0" width="100%" >
<tr>
<td height="25" colspan="3" class="topbg"><span class="B">会员参数设置</span></td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6">
会员注册:</td>
<td height="25" align="left" bgcolor="#f6f6f6">
<asp:RadioButton ID="RadioButton1" GroupName="x1" runat="server" Text="是" />
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="x1" Text="否" /></td>
<td align="center" bgcolor="#f6f6f6" >
是否允许前台会员注册</td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6">
注册审核:</td>
<td height="25" align="left" bgcolor="#f6f6f6">
<asp:RadioButton ID="RadioButton3" runat="server" GroupName="x2" Text="是" />
<asp:RadioButton ID="RadioButton4" runat="server" GroupName="x2" Text="否" /></td>
<td align="center" bgcolor="#f6f6f6" >
是否审核前台会员注册</td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6">
发送邮件:</td>
<td height="25" align="left" bgcolor="#f6f6f6">
<asp:RadioButton ID="RadioButton5" runat="server" GroupName="x3" Text="是" />
<asp:RadioButton ID="RadioButton6" runat="server" GroupName="x3" Text="否" /></td>
<td align="center" bgcolor="#f6f6f6" >
是否向注册成功的用户发送邮件</td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6">
商品发布量:</td>
<td align="left" bgcolor="#f6f6f6" height="25">
<asp:TextBox ID="Text_num" runat="server" Width="73px">10</asp:TextBox></td>
<td align="center" bgcolor="#f6f6f6">
设置一般会员的发布量</td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6">
取回密码:</td>
<td height="25" align="left" bgcolor="#f6f6f6"><asp:RadioButton ID="RadioButton11" runat="server" Text="在线通过问题取回" GroupName="x6" />
<asp:RadioButton ID="RadioButton12" Text="直接发送注册邮箱" runat="server" GroupName="x6" /></td>
<td align="center" bgcolor="#f6f6f6" >
<span class="gray">忘记密码采用何种方式</span>取回密码</td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6">
免费时间:</td>
<td height="25" align="left" bgcolor="#f6f6f6">
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="180">半年</asp:ListItem>
<asp:ListItem Value="360">一年</asp:ListItem>
<asp:ListItem Value="720">二年</asp:ListItem>
<asp:ListItem Value="1080">三年</asp:ListItem>
</asp:DropDownList>
</td>
<td align="center" bgcolor="#f6f6f6" >
<span class="gray">会员申请店铺免费的时间</span></td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6" style="height: 108px">
会员服务协议:</td>
<td align="left" bgcolor="#f6f6f6" style="width: 444px; height: 108px">
<asp:TextBox ID="TextBox14" runat="server" Height="91px" TextMode="MultiLine" Width="414px"></asp:TextBox></td>
<td align="center" bgcolor="#f6f6f6" style="height: 108px">
会员服务协议</td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6" style="height: 108px">
支付宝服务协议 :</td>
<td align="left" bgcolor="#f6f6f6" style="width: 444px; height: 108px">
<asp:TextBox ID="TextBox15" runat="server" Height="91px" TextMode="MultiLine" Width="414px"></asp:TextBox></td>
<td align="center" bgcolor="#f6f6f6" style="height: 108px">
支付宝服务协议</td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6">
</td>
<td align="left" bgcolor="#f6f6f6" height="25">
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" onmousemove=showBtnOver(this) onmouseout=showBtnOut(this) CssClass="submitMiniGreen" Text="修改参数" Width="131px" /></td>
<td align="center" bgcolor="#f6f6f6">
</td>
</tr>
</table>
</asp:Panel>
protected void Button2_Click(object sender, EventArgs e)
{
try
{
this.shopnum = Convert.ToInt32(this.Text_num.Text.Trim().ToString());
}
catch (Exception)
{
ChangeHope_fc.Show_Msg("商品发布量数量格式不正确");
}
int num = 0;
int num2 = 0;
int num3 = 0;
int num4 = 0;
int num5 = 0;
int num6 = 0;
string str = "";
StringBuilder builder = new StringBuilder();
if (this.RadioButton1.Checked)
{
num = 1;
}
if (this.RadioButton3.Checked)
{
num2 = 1;
}
if (this.RadioButton5.Checked)
{
num3 = 1;
}
if (this.RadioButton11.Checked)
{
num6 = 1;
}
str = "";
this.Exsql.Open();
builder.Append(string.Concat(new object[] { "Update YX_UserParameter Set YX_UserReg=", num, ",YX_UserVer=", num2, ",YX_SenderEmail=", num3, "," }));
builder.Append(string.Concat(new object[] { "YX_EmailConfir=", num4, ",YX_StrFilters='", str, "',YX_TJUser=", num5, ",YX_RetPwd=", num6, ",YX_ShopTime=", this.DropDownList1.SelectedValue, ",YX_Userfw=@YX_Userfw,YX_UserZFB=@YX_UserZFB where YX_ID=1" }));
SqlCommand command = new SqlCommand(builder.ToString(), this.Exsql.con);
command.Parameters.Add(new SqlParameter("@YX_Userfw", SqlDbType.Text));
command.Parameters["@YX_Userfw"].Value = this.TextBox14.Text;
command.Parameters.Add(new SqlParameter("@YX_UserZFB", SqlDbType.Text));
command.Parameters["@YX_UserZFB"].Value = this.TextBox15.Text;
command.ExecuteNonQuery();
command.Dispose();
this.sqlstr = "alter table YX_UserInfo drop constraint DF_YX_UserInfo_YX_Num";
this.Exsql.YX_ExecSql(this.sqlstr);
this.sqlstr = "alter table YX_UserInfo add constraint DF_YX_UserInfo_YX_Num default (" + this.shopnum + ") for yx_num";
this.Exsql.YX_ExecSql(this.sqlstr);
this.sqlstr = "update YX_UserInfo set yx_num=" + this.shopnum + "";
this.Exsql.YX_ExecSql(this.sqlstr);
ChangeHope_fc.Show_Msg("操作成功!", "YX_SystemWeb.aspx?YX_FS=User");
}
.aspx代码
<asp:Panel ID="Panel2" runat="server" Width="100%"> <table align="center" cellpadding="4" cellspacing="1" border="1" width="100%" class="toptable grid">
<tr>
<td height="25" class="category t2" width="100px">系统基本设置</td><td class="category">
<a href="?"> [网站基本设置]</a>
<a href="?YX_FS=User"> [网站会员参数设置]</a>
</td>
</tr>
</table>
<table align="center" cellpadding="1" cellspacing="1" border="0" width="100%" >
<tr>
<td height="25" colspan="3" class="topbg"><span class="B">会员参数设置</span></td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6">
会员注册:</td>
<td height="25" align="left" bgcolor="#f6f6f6">
<asp:RadioButton ID="RadioButton1" GroupName="x1" runat="server" Text="是" />
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="x1" Text="否" /></td>
<td align="center" bgcolor="#f6f6f6" >
是否允许前台会员注册</td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6">
注册审核:</td>
<td height="25" align="left" bgcolor="#f6f6f6">
<asp:RadioButton ID="RadioButton3" runat="server" GroupName="x2" Text="是" />
<asp:RadioButton ID="RadioButton4" runat="server" GroupName="x2" Text="否" /></td>
<td align="center" bgcolor="#f6f6f6" >
是否审核前台会员注册</td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6">
发送邮件:</td>
<td height="25" align="left" bgcolor="#f6f6f6">
<asp:RadioButton ID="RadioButton5" runat="server" GroupName="x3" Text="是" />
<asp:RadioButton ID="RadioButton6" runat="server" GroupName="x3" Text="否" /></td>
<td align="center" bgcolor="#f6f6f6" >
是否向注册成功的用户发送邮件</td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6">
商品发布量:</td>
<td align="left" bgcolor="#f6f6f6" height="25">
<asp:TextBox ID="Text_num" runat="server" Width="73px">10</asp:TextBox></td>
<td align="center" bgcolor="#f6f6f6">
设置一般会员的发布量</td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6">
取回密码:</td>
<td height="25" align="left" bgcolor="#f6f6f6"><asp:RadioButton ID="RadioButton11" runat="server" Text="在线通过问题取回" GroupName="x6" />
<asp:RadioButton ID="RadioButton12" Text="直接发送注册邮箱" runat="server" GroupName="x6" /></td>
<td align="center" bgcolor="#f6f6f6" >
<span class="gray">忘记密码采用何种方式</span>取回密码</td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6">
免费时间:</td>
<td height="25" align="left" bgcolor="#f6f6f6">
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="180">半年</asp:ListItem>
<asp:ListItem Value="360">一年</asp:ListItem>
<asp:ListItem Value="720">二年</asp:ListItem>
<asp:ListItem Value="1080">三年</asp:ListItem>
</asp:DropDownList>
</td>
<td align="center" bgcolor="#f6f6f6" >
<span class="gray">会员申请店铺免费的时间</span></td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6" style="height: 108px">
会员服务协议:</td>
<td align="left" bgcolor="#f6f6f6" style="width: 444px; height: 108px">
<asp:TextBox ID="TextBox14" runat="server" Height="91px" TextMode="MultiLine" Width="414px"></asp:TextBox></td>
<td align="center" bgcolor="#f6f6f6" style="height: 108px">
会员服务协议</td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6" style="height: 108px">
支付宝服务协议 :</td>
<td align="left" bgcolor="#f6f6f6" style="width: 444px; height: 108px">
<asp:TextBox ID="TextBox15" runat="server" Height="91px" TextMode="MultiLine" Width="414px"></asp:TextBox></td>
<td align="center" bgcolor="#f6f6f6" style="height: 108px">
支付宝服务协议</td>
</tr>
<tr>
<td align="center" bgcolor="#f6f6f6">
</td>
<td align="left" bgcolor="#f6f6f6" height="25">
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" onmousemove=showBtnOver(this) onmouseout=showBtnOut(this) CssClass="submitMiniGreen" Text="修改参数" Width="131px" /></td>
<td align="center" bgcolor="#f6f6f6">
</td>
</tr>
</table>
</asp:Panel>
然后把探测到的sql语句在查询分析器里执行下就明白是什么原因了
sql语句正确 不代表他是有效的 debug看看提交时的sql语句 那些待插入或者待更新的数据是否是你预期的?