我想写入数据库,但是数据库的字段类型是数字型,我用的是ACCESS,如何将TextBox中的内容转换为数字,
using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class net_example_wyg8 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String StrConn = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " + Server.MapPath(".") + "..\\..\\Data\\wyg.mdb;";
String selStr = "insert into Score(UserName,Maths,English,Chinese) values('"+UserName.Text+"','"+Maths.Text+"','"+English.Text+"','"+Chinese.Text+"')";
OleDbConnection Myconn = new OleDbConnection(StrConn);
OleDbCommand MyCommand = new OleDbCommand(selStr, Myconn);
Myconn.Open();
MyCommand.ExecuteNonQuery();
Myconn.Close();
}
}
我知道可以用Int32.Parse或Convert.ToInt32,但是具体在哪儿转换呢,本人初学,谢谢!