熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

用戶信息的查看、修改和刪除[4]

2013-11-13 11:07:07  來源: .NET編程 
    ——此文章摘自《ASPNET +SQL Server網絡應用系統開發案例精解》定價 特價 詳細>>http://tracklinktechcn/?m_id=dangdang&a_id=A&l=&l_type= width= height= border= nosave>

             string STstrsql=update STUser set STNoAdmin = @STNoAdmin STNickName =@STNickName STUserName = @STUserName  where STUserID = @STUserID;
             //創建SqlCommand對象對sql語句進行操作
             SqlCommand STcmd=new SqlCommand(STstrsqlSTconn);
             try
             {
                       //添加參數
                       STcmdParametersAdd(new SqlParameter(@STUserIDSqlDbTypeInt));
                       STcmdParametersAdd(new SqlParameter(@STNickNameSqlDbTypeVarChar));
                       STcmdParametersAdd(new SqlParameter(@STUserNameSqlDbTypeVarChar));
                       STcmdParametersAdd(new SqlParameter(@STNoAdminSqlDbTypeInt));
                       string stupdatetext=((TextBox)eItemCells[]Controls[])Text ;
                       STcmdParameters[@STNickName]Value=stupdatetext;
                       stupdatetext=((TextBox)eItemCells[]Controls[])Text;
                       STcmdParameters[@STUserName]Value=stupdatetext;
                       stupdatetext=((TextBox)eItemCells[]Controls[])Text;
                       STcmdParameters[@STNoAdmin]Value=stupdatetext;
                                                 
             STcmdParameters[@STUserID]Value=STmyGridDataKeys[(int)eItemItemIndex];
                       //打開連接
                       STcmdConnectionOpen();    
                       //執行非查詢             
                       STcmdExecuteNonQuery();
                       STmyGridEditItemIndex=;
             }
             catch(SqlException ex)
             {
                       throw ex;
             }
             //關閉連接
             STcmdConnectionClose();             
             BindGrid();      
    }

    ()響應取消事件
    //單擊取消按鈕所觸發的事件
    public void STmyGrid_cancel(object source SystemWebUIWebControlsDataGridCommandEventArgs e)
    {
             //獲取DataGrid所要編輯的項的索引為
             STmyGridEditItemIndex=;
             BindGrid();
    }

right>[http://developcsaicn/dotnet_ASP/htm>]  [http://developcsaicn/dotnet_ASP/htm>]  [http://developcsaicn/dotnet_ASP/htm>]  []  [http://developcsaicn/dotnet_ASP/htm>]  


From:http://tw.wingwit.com/Article/program/net/201311/15192.html
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.