asp.net关于TextBox.Text的值为空时,将string数据插入到数据库中int数据的问题的解决方法

如代码所示:

public partial class Teacher_courseopen : System.Web.UI.Page
{
    public static string tid;
    public static string txt5 = null;
    public static string txt6 = null;
    public static string txt7 = null;
    public static string txt8 = null;
    public static string txt19 = null;

...............................................................

...............................................................

}

//事件

{

 if (TextBox5.Text != "")
            txt5 = TextBox5.Text;
        if (TextBox6.Text != "")
            txt6 = TextBox6.Text;
        if (TextBox7.Text != "")
            txt7 = TextBox7.Text;
        if (TextBox8.Text != "")
            txt8 = TextBox8.Text;
        if (TextBox19.Text != "")
            txt19 = TextBox19.Text;//先判定textbox中的值

   string="insert ito 数据库 Values(.....)";

.........................................................................

...........................................................................

.........................................................................//插入操作

       txt5 = null;
        txt6 = null;
        txt7 = null;
        txt8 = null;
        txt19 = null;

}

这样子,Convert.ToInt32(txt5)传入到数据库中如果数据库中要求是INT,则插入成功。

  

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值