请帮忙看看下面的ASP代码有何什么不对?
用一个ASPX页面来实现录入邮票的名称、编码、发行量。
<%@ Page Language=C# Debug=True %>
<%@ Import Namespace= "System.Data " %>
<%@ Import Namespace= "System.Data.OleDb " %>
<script runat= "server ">
public void BtnSave_Click(Object sender, EventArgs e){
string CnnString= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= "+Server.MapPath( "Stamp.MDB ");
OleDbConnection cnn = new OleDbConnection(CnnString);
string StrSql= "Select * from Stamp ";
DataSet Ds=new DataSet();
OleDbDataAdapter Adapter=new OleDbDataAdapter(StrSql,cnn);
OleDbCommandBuilder Cb=new OleDbCommandBuilder(Adapter);
Adapter.Fill(Ds, "Stamp ");
DataRow Dr;
Dr=Ds.Tables[ "Stamp "].NewRow();
Dr[ "StampName "]=txtStampName.Text;
Dr[ "StampNO "]=txtStampNo.Text;
Dr[ "Amount "]=txtAmount.Text;
Ds.Tables[ "Stamp "].Rows.Add(Dr);
Adapter.Update(Ds, "Stamp ");
Response.Redirect( "KLine.aspx ");
}
</script>
<html>
<body>
<form runat= "server ">
<asp:Label ID= "lblStamp " Text= "名称: " runat= "server " font-size= "13px " />
<asp:TextBox ID= "txtStampName " runat= "server " />
<asp:Label ID= "lblStampNo " Text= "编码: " runat= "server " font-size= "13px " />
<asp:TextBox ID= "txtStampNo " runat= "server " />
<asp:Label ID= "lblAmount " Text= "发行量: " runat= "server " font-size= "13px " />
<asp:TextBox ID= "txtAmount " runat= "server " />
<asp:Button ID= "BtnSave " runat= "server " Text= "保存 " OnClick= "BtnSave_Click " />
</form>
</body> </html>
点击BtnSave按钮后,执行没有报任何错误,但去打开ACCESS数据库,发现只能以“只读”方式打开,打开后数据库纪录没有写入。
------解决方案--------------------你这种方法我没用过,帮你顶。