——此文章摘自《ASPNET +SQL Server网络应用系统开发案例精解》定价¥特价¥ 详细>>http://tracklinktechcn/?m_id=dangdang&a_id=A&l=&l_type= width= height= border= nosave> .连锁店信息的添加 单击左边链接的添加连锁店信息进入连锁店管理界面STAddDepaspx如图所示 http://developcsaicn/dotnet_ASP/images/jpg> 图 添加连锁店界面 此界面负责实现连锁店信息的添加 STAddDepaspxcs的核心代码及其解释如下当管理员单击添加按钮后会首先验证填写的数据是否合法合法则生成一个 SqlCommand类型的实例STcmd并把管理员填写的数据赋值给Stcmd要执行的存储过程的参数之后执行插入的存储过程 insert_STDep_ private void Page_Load(object sender SystemEventArgs e) { if(Session[STNickName] != null) { //获得数据库连接字符串 string STconnection = ConfigurationSettingsAppSettings[strconnection]; //创建数据库的SqlConnection STconn = new SqlConnection(STconnection); } else { ResponseRedirect(/Indexaspx); } } private void STDe_add_Click(object sender SystemEventArgs e) { if(STDeNameText == ) { STDe_warnText = 名称不能为空!; } else if(STDeMasterText == ) { STDe_warnText = 负责人不能为空!; } else { //创建数据库的SqlCommand对象 SqlCommand STcmd = new SqlCommand(insert_STDep_STconn); //定义访问数据库的方式为存储过程 STcmdCommandType = CommandTypeStoredProcedure; //为存储过程添加参数 STcmdParametersAdd(new SqlParameter(@STDepNameSqlDbTypeVarChar)); right>[http://developcsaicn/dotnet_ASP/htm>] [http://developcsaicn/dotnet_ASP/htm>] [http://developcsaicn/dotnet_ASP/htm>] [] [http://developcsaicn/dotnet_ASP/htm>] |