我现在正在做课程设计,遇到了点问题,想向各位高手请教一下。
我设计了一个登陆界面,需输入用户章号和密码,我将用户申请的章号和密码放入了Access数据库,但是我编的代码怎么也实现不了从数据库检测章号和密码。不知哪位高手能给我解答一下,最好告诉我原代码,小弟在这里先说一声谢谢了!!
我也刚学 错误之处请指出 我的代码跟楼上的兄弟不一样 那是因为我是纯代码的 只要把代码复制就可以用了 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try
Dim dt12 As DataTable Dim conn12 As New OleDb.OleDbConnection(strConnect = "Provider=SQLOLEDB;User ID=sa;password=;database=数据库名;server=服务器名" Dim da12 As New OleDb.OleDbDataAdapter("select * from CommomEmployee", conn12) da12.TableMappings.Add("Table12", "CommomEmployee") conn12.Open() Dim ds12 As New DataSet da12.Fill(ds12, "Table12") dt12 = ds12.Tables("CommomEmployee") ’如果用水晶报表时 da12为数据源 dt12为数据集 Dim iRowCount12 As Integer Dim flag12 As Boolean = False For iRowCount12 = 0 To dt12.Rows.Count - 1 ‘从数据集第一行搜索到最后一行 If dt12.Rows.Item(iRowCount12)("ID").ToString.Trim = txt1.Text And dt12.Rows.Item(iRowCount12)("PostCard").ToString.Trim = txt2.Text Then flag12 = True End If Next if flag12=Ture Then dim form2 as new form2 ‘form2为第二个窗口 me.close() form2.show() Else MsgBox("输入错误或帐号不存在!", MsgBoxStyle.Exclamation) txt1.Clear() txt2.Clear() cmb1.Text = "" End If conn12.Close() Catch ex As Exception MsgBox("系统发生错误,请确定操作正确!" & ex.ToString, MsgBoxStyle.Critical) End Try End Sub
[此贴子已经被作者于2005-1-23 17:48:26编辑过]