您现在的位置: 军旅同心-旅游自驾-军旅文学 >> 读书赏析 >> 学习园地 >> 电脑网络 >> 技术文章 >> 正文
asp.net高级教程(三)-实战篇
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005-9-10 12:37:00
;                  m_strPassword = myReader["password"].ToString() ;
                    m_strEmail = myReader["Email"].ToString() ;
                    m_strHomepage = myReader["Homepage"].ToString() ;
                    m_strSignature = myReader["Signature"].ToString() ;
                    bExists = true ;
                }
                else
                {
                    bExists = false ;
                }

                myReader.Close() ;
                myConn.Close() ;
                
            }
            catch(SQLException e)        //如果出现异常
            {

                throw(new Exception("数据库异常:" + e.Message)) ;
                
            }                    

            //返回结果
            return bExists ;            
        }

        //重载,根据用户ID查找用户
        public bool GetUser(int a_intUserID)
        {

            bool bExists = false ;

            MyConnection myConn = new MyConnection() ;
            try
            {
                myConn.Open() ;
                SQLCommand myCommand = new SQLCommand() ;
                myCommand.ActiveConnection = myConn ;
                myCommand.CommandText = "select * from BBSUser where id=" +

a_intUserID.ToString() ;

                SQLDataReader myReader ;
                myCommand.Execute(out myReader) ;
                
                if (myReader.Read())
                {
                    m_intID = (int)myReader["ID"] ;
                    m_strUserName = myReader["UserName"].ToString() ;
                    m_strPassword = myReader["password"].ToString() ;
                    m_strEmail = myReader["Email"].ToString() ;
                    m_strHomepage = myReader["Homepage"].ToString() ;
                    m_strSignature = myReader["Signature"].ToString() ;
                    bExists = true ;
                }
                else
                {
                    bExists = false ;
                }

                myReader.Close() ;
                myConn.Close() ;
                
            }
            catch(SQLException e)        //如果出现异常
            {

                throw(new Exception("数据库异常:" + e.Message)) ;
                
            }                    

            //返回结果
            return bExists ;            
        }

        //新建用户
        public void CreateUser(BBSUser.CreateType a_enumCreateType ,string

a_strUserName ,
                                string a_strPassword ,

string a_strEmail ,
                                string a_strHomepage ,

string a_strSignature)
        {
            //监测参数有效性
            if (a_strUserName.IndexOf("'") != -1 || a_strPassword.IndexOf("'")

!= -1
                || a_strEmail.IndexOf("'") != -1 ||

a_strHomepage.IndexOf("'") != -1
                || a_strSignature.IndexOf("'") != -1)
            {
                throw(new Exception("包含非法字符")) ;
            }

            try
            {
                MyOwnClass.MyConnection myConn = new MyConnection() ;
                SQLCommand myCmd = new SQLCommand() ;

                //判断是新建用户还是修改用户资料
     &

上一页  [1] [2] [3] 下一页


更多
免责声明:作品版权归所属媒体与作者所有!!本站刊载此文不代表同意其说法或描述,仅为提供更多信息。如果您认为我们侵犯了您的版权,请告知!本站立即删除。有异议请联系我们。
文章录入:烟灰缸    责任编辑:烟灰缸 
网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
| 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 网站地图 | 版权申明 | 网站公告 | 管理登录 |