求助各位:我初识ASP.net,我的数据库中有以下字段:学号,姓名,性别,成绩,往数据库中插入记录,我的操作如下:
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="gb2312" %>
<script language="VB" runat="server">
sub tijiao(sender as Object,e as EventArgs)
'dim chengji as integer=convert.toint16(cj.text)
Dim myconnstring as string="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath("aspnet1.mdb")
Dim myconnection as OleDbConnection=new OleDbConnection(myconnstring)
dim insertsqlstring as string="insert into student(学号,姓名,性别,成绩) values('"+xh.text+"','"+xm.text+"','"+xb.selecteditem.text+"','"+cj.text+"')"
Dim mycommand as OleDbCommand=new OleDbcommand(insertsqlstring,myconnection)
myconnection.open()
mycommand.executenonquery()
myconnection.close()
end sub
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>数据提交</title>
</head>
<body>
<p>数据库中插入数据</p>
<form runat="server">
<p>学号
<asp:textbox ID="xh" runat="server" />
姓名
<asp:textbox ID="xm" runat="server" />
</p>
<p>性别
<asp:dropdownlist ID="xb" runat="server">
<asp:listitem>男</asp:listitem>
<asp:listitem>女</asp:listitem>
</asp:dropdownlist>
成绩
<asp:textbox ID="cj" runat="server" />
</p>
<p>
<asp:button Onclick="tijiao" ID="tj" runat="server" Text="提交" />
</p>
</form>
<p> </p>
</body>
</html>
1、为何在“姓名”中不能输入中文?用英文不出错,而用中文就出错,字符串长度为0
2、现在:“成绩”用的是字符,改为数值后,insert语句应怎么写?
3、下拉列表为何一直选“男”?
请各位高手指教,非常感谢!
[求助]为何不能用中文字符?