-
another problem again ~~
ok ~~~
i try already ~
u sample code u send to me is working ~
but when i modify my code
it cannot run, ai ~~ donno y like that
it will come out an error like
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.windows.forms.dll
-
-
Imports System.Data
Imports System.Data.OleDb
Public Class loginpage
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents user As System.Windows.Forms.TextBox
Friend WithEvents pass As System.Windows.Forms.TextBox
Friend WithEvents login As System.Windows.Forms.Button
Friend WithEvents clear As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.user = New System.Windows.Forms.TextBox
Me.pass = New System.Windows.Forms.TextBox
Me.login = New System.Windows.Forms.Button
Me.clear = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(64, 104)
Me.Label1.Name = "Label1"
Me.Label1.TabIndex = 0
Me.Label1.Text = "Username "
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(64, 136)
Me.Label2.Name = "Label2"
Me.Label2.TabIndex = 1
Me.Label2.Text = "Password "
'
'user
'
Me.user.Location = New System.Drawing.Point(128, 104)
Me.user.Name = "user"
Me.user.TabIndex = 2
Me.user.Text = ""
'
'pass
'
Me.pass.Location = New System.Drawing.Point(128, 136)
Me.pass.Name = "pass"
Me.pass.TabIndex = 3
Me.pass.Text = ""
'
'login
'
Me.login.Location = New System.Drawing.Point(64, 184)
Me.login.Name = "login"
Me.login.TabIndex = 4
Me.login.Text = "Login"
'
'clear
'
Me.clear.Location = New System.Drawing.Point(152, 184)
Me.clear.Name = "clear"
Me.clear.TabIndex = 5
Me.clear.Text = "Clear "
'
'loginpage
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.clear)
Me.Controls.Add(Me.login)
Me.Controls.Add(Me.pass)
Me.Controls.Add(Me.user)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "loginpage"
Me.Text = "Welcome to Sean Restaurant"
Me.ResumeLayout(False)
End Sub
#End Region
Dim mypath = Application.StartupPath & "\restaurantbookingsystem.mdb"
Dim mypassword = ""
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mypath & ";Jet OLEDB:Database Password=" & mypassword)
Dim cmd As OleDbCommand
Private Sub login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles login.Click
Dim sql = "SELECT username ,userid FROM Employee WHERE USERID='" & user.Text & "' AND PASSID='" & pass.Text & "'"
cmd = New OleDbCommand(sql, conn)
conn.Open()
Dim dr As OleDbDataReader = cmd.ExecuteReader
Try
If dr.Read = False Then
MessageBox.Show("Authentication failed...")
Else
MessageBox.Show("Login successfully...")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
conn.Close()
End Sub
End Class
-
In which line you get that error and where is your database located(path) ??
-
i set my database inside my project folder call bin ~
and when the problem come
it pointer here --> Public Class loginpage
and one time is pointer -> Dim dr As OleDbDataReader = cmd.ExecuteReader
and i using the office 2003
is there got anyproblem with the version of office in this problem ??
-
I don't know about the new access db (2003) . Can you upload the proj ?
-
i found out the problem ~~~~
i delete the the database than create a new one and save it at the bin in my project ~~
thank you for you help ~~
i very very appreciate for you help
thank you