2 Replies - 15049 Views - Last Post: 16 March 2011 - 04:24 AM Rate Topic: -----

#1 Suigetsu  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 08-August 09

Simple Menu,Registration and Log-in Form

Posted 15 March 2011 - 09:26 PM

I want to make a simple Menu, Registration and log-in form. If i click register the registration form will pop out, if i click log-in the log-in form will pop out and if i click cancel it will close.
Problem:The code works but every time i input a username and password it doesn't add up to my database which i created from MS Access. I tried using the code for registration and it works just fine but if i put 2 more forms it doesn't add up to my database.
Thanks

Code for Menu form:
Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)
Handles Button1.Click

Dim x as Form1 = New Form1
x.Hide()
me.Show()

End Sub
End Class

Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)
Handles Button2.Click

Dim y as Form2 = New Form2
y.Hide()
me.Show()

End Sub
End Class

Private Sub Button2_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)
Handles Button2.Click

Dispose()

End Sub
End Class


Code for registration:
Private Sub Form2_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)
Handles MyBase.Load

End Sub

Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)
Handles Button1.Click
Try
cn = New OleDbConnection("Provider=Microsoft.Jet >OLEDB.4.0;Data Source=D:\megaera\data.mdb;")
cn.Open()
str = "insert into table1 values("&Textbox1.Text&",'"&Textbox1.Text&"')"
cmd = New OleDbCommand(str,cn)
MessageBox.Show("Registration Success!!")

Catch
End Try
cn.Close()
End Sub
End Class


I'm still searching for a code for the log-in form.

Is This A Good Question/Topic? 0
  • +

Replies To: Simple Menu,Registration and Log-in Form

#2 polens  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 155
  • Joined: 09-November 09

Re: Simple Menu,Registration and Log-in Form

Posted 15 March 2011 - 09:44 PM

for your login you will query for the username and password..
"SELECT * FROM tblUserAccounts WHERE username='"& txtUserName.text &"' AND Password='"& txtUserName.text &"' "
You may convert this to parameters...

to check if there is a "HIT"

Put it in a dataAdapter
"oledbdataadapter.fill(datatable)"

then
'if their are hits
if dt.rows.count > 0 then
successfully login
else
incorrect
end if
Was This Post Helpful? 0
  • +
  • -

#3 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: Simple Menu,Registration and Log-in Form

Posted 16 March 2011 - 04:24 AM

It doesn't add to your database because you're not executing the command

Add this right before your msgbox("Registration Success!!") line

cmd.ExecuteNonQuery()

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1