sqlinsert.aspx

来自「asp.net技术内幕的书配源码」· ASPX 代码 · 共 21 行

ASPX
21 行
字号
<%@ Page Language="C#"%>
<%@ Import Namespace="System.Data.SqlClient" %>

<script runat=server>

void Page_Load(Object sender , EventArgs e) 
{
	SqlConnection conNorthwind;
	string  strInsert;
	SqlCommand cmdInsert;

	conNorthwind = new SqlConnection( @"Server=localhost;Integrated Security=SSPI;database=Northwind" );
	strInsert = "Insert Products ( ProductName, UnitPrice ) Values ('Milk', 12.45 )";
	cmdInsert = new SqlCommand( strInsert, conNorthwind );
	conNorthwind.Open();
	cmdInsert.ExecuteNonQuery();
	conNorthwind.Close();
	Response.Write("New Product Added!");
}
</script>

⌨️ 快捷键说明

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