| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 392 人关注过本帖
标题:感觉这个类写的有点问题,
取消只看楼主 加入收藏
c120110
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2006-2-19
收藏
 问题点数:0 回复次数:0 
感觉这个类写的有点问题,

看一下我的这个类有什么问题,帮忙修改下!谢谢了
imports system
imports system.data
imports system.data.sqlclient
Namespace xiazhifeng
public class register
private _username as string
private _userpassword as string
private _name as string
private _address as string
private _email as string
private _description as string
private _info as string
public property username as string
get
return _username
end get
set
_username=value
end set
end property
public property userpassword as string
get
return _userpassword
end get
set
_userpassword=value
end set
end property
public property name as string
get
return _name
end get
set
_name=value
end set
end property
public property address as string
get
return _address
end get
set
_address=value
end set
end property
public property email as string
get
return _email
end get
set
_email=value
end set
end property
public property description as string
get
return _description
end get
set
_description=value
end set
end property
public property info as string
get
return _info
end get
set
_info=value
end set
end property
public function check as boolean
if _username="" then
_info="请输入用户名"
return false
exit function
end if
if _userpassword="" then
_info="请输入密码"
return false
exit function
end if
dim sqlcon as new sqlconnection("server=localhost;uid=sa;pwd=sa;database=register")
sqlcon.open
dim sqld as new sqlDataAdapter("select * from users where uesrid='&_username' and psw='&_userpassword'",sqlcon)
dim ds as new dataset
sqld.fill(ds,"user")
if ds.tables("user").rows.count=0 then
_info="登陆失败"
return false
else
_info="登陆成功"
return true
end if
sqlcon.close
sqlcon=nothing
sqld=nothing
ds=nothing
end function
public function adduser as boolean
on error goto err1
dim sqlcon as new sqlconnection("server=localhost;uid=sa;pwd=sa;database=register")
sqlcon.open()
dim strsql as string
strsql="INSERT INTO users(userid,psw,name,address,email,description)VALUE('&_username','&_userpassword','&_name','&_address','&_description')"
dim sqlcom as new sqlcommand
sqlcom.connection=sqlcon
sqlcom.commandtext=strsql
sqlcom.executenonquery
sqlcon.close()
sqlcon=nothing
sqlcom=nothing
adduser=true
exit function
err1:
adduser=false
end function
public function deleteuser as boolean
on error goto err2
dim sqlcon as new sqlconnection("server=localhost;uid=sa;pwd=sa;database=register")
sqlcon.open()
dim strsql as string
strsql="delete from users where userid="&_username
dim sqlcom as new sqlcommand
sqlcom.connection=sqlcon
sqlcom.commandtext=strsql
sqlcom.executenonquery
sqlcon.close()
sqlcon=nothing
sqlcom=nothing
deleteuser=true
exit function
err2:
deleteuser=false
end function
public function updatepsw as boolean
on error goto err3
dim sqlcon as new sqlconnection("server=localhost;uid=sa;pwd=sa;database=register")
sqlcon.open()
dim strsql as string
strsql="update users set psw='&_userpassword' where userid="&_username
dim sqlcom as new sqlcommand
sqlcom.connection=sqlcon
sqlcom.commandtext=strsql
sqlcom.executenonquery
sqlcon.close()
sqlcon=nothing
sqlcom=nothing
updatepsw=true
exit function
err3:
updatepsw=false
end function
public function queryuser as boolean
dim sqlcon as new sqlconnection("server=localhost;uid=sa;pwd=sa;database=register")
sqlcon.open()
dim strsql as string
strsql="select * from users where userid="'&_username'""
dim sqlreader as sqlDataReader
dim sqlcom as new sqlcommand
sqlcom.connection=sqlcon
sqlcom.commandtext=strsql
sqlreader=sqlcom.executereader
if sqlreader.read then
_username=sqlreader.item("userid")
_userpassword=sqlreader.item("psw")
_name=sqlreader.item("name")
_address=sqlreader.item("address")
_email=sqlreader.item("email")
_description=sqlreader.item("description")
queryuser=true
else
queryuser=false
end if
sqlcon.close()
exit function
err4:
queryuser=false
end function
public function updateinfo as boolean
on error goto err5
dim sqlcon as new sqlconnection("server=localhost;uid=sa;pwd=sa;database=register")
sqlcon.open
dim strsql as string
strsql="update users set name='&_name',address='&_address',email='&_email',description='&_description&' where userid="&_username
dim sqlcom as new sqlcommand
sqlcom.connection=sqlcon
sqlcom.commandtext=strsql
sqlcom.executenonquery
sqlcon.close
sqlcon=nothing
sqlcom=nothing
updateinfo=true
exit function
err5:
updateinfo=false
end function
public function queryemail as boolean
on error goto err6
dim sqlcon as new sqlconnection("server=localhost;uid=sa;pwd=sa;database=register")
sqlcon.open
dim strsql as string
strsql="select * from users where userid='&_username'and email="&_email
dim sqlreader as sqlDataReader
dim sqlcom as new sqlcommand
sqlcom.connection=sqlcon
sqlcom.commandtext=strsql
sqlreader=sqlcom.executereader
if sqlreader.read then
_username=sqlreader.item("userid")
_userpassword=sqlreader.item("psw")
_name=sqlreader.item("name")
_address=sqlreader.item("address")
_email=sqlreader.item("email")
_description=sqlreader.item("description")
queryemail=true
else
queryemail=false
end if
exit function
err6:
queryemail=false
end function
public function queryalluser as dataset
dim sqlcon as new sqlconnection("server=localhost;uid=sa;pwd=sa;database=register")
dim ds as new dataset
sqlcon.open
dim sqld as new sqlDataAdapter("select * from users",sqlcon)
sqld.fill(ds,"tabuser")
queryalluser=ds
sqlcon=nothing
sqld=nothing
end function
end class
end Namespace

2006-08-03 12:22
快速回复:感觉这个类写的有点问题,
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016701 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved