如代码所示:
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,则插入成功。