vb.net对access进行的操作

tamadgebi 2009-07-13 10:32:59
我是用access数据库做的登陆界面,其中一个就是提示“该用户名不存在”,这个是怎么实现的啊,究竟怎么去数据库中判断没改用户名的啊。
谁给我个实例啊数据库“denglu”表“yonghu”字段“zhanghao”字段“密码”。
在线等啊
...全文
185 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
古今多少事 2009-07-13
  • 打赏
  • 举报
回复
参考:
http://topic.csdn.net/u/20090712/21/6dd2818c-1680-49e6-8516-fee9925419d7.html?72032
米か臹 2009-07-13
  • 打赏
  • 举报
回复
dim strSql as string

strSql = "select * from table where yonghu = "'+txtUser.text+'" " 'txtUser为等录用户
根据上面的strSql 去得到Datatable dt,根据dt.rows.count是否大于0就可以知道这个用户是否存在与数据库中
gba8jing 2009-07-13
  • 打赏
  • 举报
回复
Do While ord.Read()
If obs1 = ord("yonghu") And obs2 = ord("zhanghao") Then

xxoo = True
Exit Do '上面少写上了这个,自己补上去
gba8jing 2009-07-13
  • 打赏
  • 举报
回复
Public Function inuser(ByVal obj1 As String, ByVal obj2 As String) As Boolean
'cn = Oledb 连接字串
'str= 查询字串


Dim xxoo As Boolean = false

Dim obs1 As String
Dim obs2 As String
obs1 = obj1
obs2 = obj2

Dim conn As New OleDb.OleDbConnection(cn)
Dim comm As New OleDb.OleDbCommand(str, conn)
conn.Open()
Dim ord As OleDb.OleDbDataReader = comm.ExecuteReader

Do While ord.Read()
If obs1 = ord("yonghu") And obs2 = ord("zhanghao") Then

xxoo = True

Else
xxoo = False
End If
Loop
If xxoo = True Then
Return True
Else
Return False
End If
ord.Close()
conn.Close()
End Function

调用 inuser(用户名,密码) 如果用户密码相同时返回 true , 否则返回 false

可以这样写:
if inuser(用户名,密码) = true then
msgbox("登录成功")
else
msgbox("登录失败")
end if
outou 2009-07-13
  • 打赏
  • 举报
回复
代码中有一个判断,“dsUser ”是查询结果存放的DataSet,“M_USER”是存放结果的表名,下面的判断就是判断用户是否存在。不知为什么不明白。

'データ有無判断
If dsUser Is Nothing OrElse _
dsUser.Tables("M_USER") Is Nothing OrElse _
dsUser.Tables("M_USER").Rows.Count = 0 Then
MsgBox("该用户不存在")
Exit Sub
End If

tamadgebi 2009-07-13
  • 打赏
  • 举报
回复
上次那个不行啊,所以我才再问的,看到我的字段了?大哥们详细
outou 2009-07-13
  • 打赏
  • 举报
回复
tamadgebi 2009-07-13
  • 打赏
  • 举报
回复
二楼的大哥,说的详细点啊,这问题困扰我很久拉

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧