dataadd.aspx

来自「用VB实现」· ASPX 代码 · 共 50 行

ASPX
50
字号
<%@ Page Language="VB" ContentType="text/html" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<script runat="server">
    Dim strConn as String =  _ 
		           "Provider=Microsoft.Jet.OLEDB.4.0;" & _
				   "Data Source=" & Server.MapPath(".../bin/sales.mdb") & ";" & _
				   "Persist Security Info=False"
	Dim objConn as  New System.Data.Oledb.oledbConnection(strConn) 
	
	Sub btnAddNew_Click(sender As Object, e As System.EventArgs)
	    Dim strSQL as String  =  _ 
		    "INSERT INTO " & _ 
			"Products(ProductID,ProductName,SupplierID,UnitPrice) "  & _ 
			"VALUES('" & txtProductID.Text & "','" & txtProductName.Text & "','" &  _
			            txtSupplierID.Text & "','" & txtUnitPrice.Text &  "')" 
			
		Dim ObjComm as New System.Data.Oledb.OleDbCommand(strSQL,objConn)
		
		objConn.Open()
		ObjComm.ExecuteNonQuery
		objConn.Close() 
			
	End Sub 	

</script>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>添加商品</title>
</head>
<body>
<form runat ="server">
 <asp:Label ID="lblProductID" runat="server" Text="商品编号"></asp:Label>
 <asp:TextBox ID="txtProductID" runat="server" />
 <br> <br>
 <asp:Label ID="lblProductName" runat="server" Text="商品名称"></asp:Label>
 <asp:TextBox ID="txtProductName" runat="server" />
 <br> <br>
 <asp:Label ID="lblUnitPrice" runat="server" Text="商品单价"> </asp:Label>
 <asp:TextBox ID="txtUnitPrice" runat="server" />
 <br> <br>
 <asp:Label ID="lblSupplierID" runat="server" Text="供应商编号"> </asp:Label>
 <asp:TextBox ID="txtSupplierID" runat="server" />
 
 <asp:Button ID="btnAddNew" Text="添加" runat="server"  OnClick="btnAddNew_Click"/>
</form> 
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?