| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1949 人关注过本帖
标题:登录界面连接数据库问题
取消只看楼主 加入收藏
yulphoenix
Rank: 1
等 级:新手上路
帖 子:55
专家分:0
注 册:2005-10-27
收藏
 问题点数:0 回复次数:1 
登录界面连接数据库问题

我也做一个登录界面可是也不行,代码如下:
各位朋友看看是哪出错了,程序可以运行,但不论我输入什么,都提示“没有该用户”
Imports System.Data
Imports System.Data.oledb
Public Class Frmlogin
Inherits System.Windows.Forms.Form
Public adocmd As oledbDataAdapter
Public ds As DataSet = New DataSet
Public mytable As Data.DataTable
Public myrow As Data.DataRow
Public rownumber As Integer
Public searchsql As String
Public cmd As oledbCommandBuilder
Private Sub BtnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOK.Click
Try
Me.Text = "正在验证...."
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
Dim tablename As String
tablename = "userID"
searchsql = "select 用户名,密码 from userID where(用户名='" & Txtusername.Text & " ')"

Executesql(searchsql, tablename)
If myrow.Item(1) = txtuserpassword.text Then

Dim newfrmmain As New Frmmain
newfrmmain.Show()
Me.Hide()
Else
MsgBox("密码错误")
Txtuserpassword.Text = ""
Me.Text = ""
Me.Cursor = System.Windows.Forms.Cursors.Arrow
Txtuserpassword.Focus()


End If

Catch ex As Exception
MsgBox("用户名不存在!", MsgBoxStyle.OKOnly, "提示")
Txtusername.Text = ""
Txtuserpassword.Text = ""
Me.Text = ""
Me.Cursor = System.Windows.Forms.Cursors.Arrow


End Try
End Sub

Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCancel.Click
Me.Dispose()
End Sub
Public Function Executesql(ByVal sql As String, ByVal table As String)
adocmd = New OleDbDataAdapter(sql, "provider=microsoft .jet.oledb.4.0;data source=c:\student")
adocmd.Fill(ds, table)
mytable = ds.Tables.Item(0)
rownumber = 0
myrow = mytable.Rows.Item(rownumber)

End Function
End Class
大家帮忙看看!! 数据库是ACCESS做的,

搜索更多相关主题的帖子: 数据库 界面 登录 
2006-05-05 12:30
yulphoenix
Rank: 1
等 级:新手上路
帖 子:55
专家分:0
注 册:2005-10-27
收藏
得分:0 
我已经找到问题了 是后台数据库出了点问题,已经解决了
谢谢大家帮忙!
2006-05-25 12:54
快速回复:登录界面连接数据库问题
数据加载中...
 
   



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

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