Jump to content

Wierd Problem

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
SirTech

SirTech

    Newbie

  • Members
  • Pip
  • 2 posts
Anyone know whats rong with this?

Imports System.Data.SqlClient
Imports MySql.Data.MySqlClient

Public Class Login
Dim MySqlConnection As MySqlConnection

Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
MySqlConnection = New MySqlConnection
MySqlConnection.ConnectionString = "server=!;Port=!; user id=!; password=intel; database=!"
MySqlConnection.Open()

Dim Myadapter As New MySqlDataAdapter
Dim sqlquary = "Select * From Users WHERE Username='" & UsernameTextBox.Text & "'AND Password='" & PasswordTextBox.Text & "';"
Dim command As New MySqlCommand
command.Connection = MySqlConnection
command.CommandText = sqlquary
Myadapter.SelectCommand = command
Dim Mydata As MySqlDataReader
Mydata = command.ExecuteReader
If Mydata.HasRows = 0 Then
MsgBox("Error! Wrong Login Information")
Else
MySqlConnection.Close()
Form1.Show()
Me.Close()
End If
End Sub



Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
Me.Close()
End Sub
End Class


Im trying to make it after you login, you close the login form and open the other form but its not working :/, it just closes both forms

#2
Ray Tawil

Ray Tawil

    Programmer

  • Members
  • PipPipPipPip
  • 108 posts
Form1.Show()
Me.Close()

just re-order these:

Me.Close()
Form1.Show()

if this is the main form in vb.net you can't close it :) or at least not in this way,

if the error prusuies,
just make the following

Me.hide()
Form1.Show()
Share your Knowledge, It's one way to achieve immortality.
Video Tutorial Channel

#3
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts

Ray Tawil said:


if this is the main form in vb.net you can't close it :) or at least not in this way,


This is actually wrong. Just set 'Shutdown mode' to 'When last form closes' in the My Project/Application page. :)

#4
Ray Tawil

Ray Tawil

    Programmer

  • Members
  • PipPipPipPip
  • 108 posts

Vswe said:

This is actually wrong. Just set 'Shutdown mode' to 'When last form closes' in the My Project/Application page. :)


or at least not in this way <------

:)
Share your Knowledge, It's one way to achieve immortality.
Video Tutorial Channel

#5
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
I saw that, but "this way" is the way you said (i.e the code) and that's still the way you use to make it work. :)

#6
Ray Tawil

Ray Tawil

    Programmer

  • Members
  • PipPipPipPip
  • 108 posts

Vswe said:

I saw that, but "this way" is the way you said (i.e the code) and that's still the way you use to make it work. :)

My point was not to confuse the guy with a problem other then the one he is already in. :)
Share your Knowledge, It's one way to achieve immortality.
Video Tutorial Channel