Hi i have a program in which i want the main form to get information either from the login form or from the sign up form depending on which one is used. Here is the code below. The information does not seem to appear although there is no error. Please help me because i dont know what is wrong.
Imports System.Data.SqlClient
Public Class Home
Public Acc_no As Integer
Private password As String
Private Sub Home_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim conn As New SqlConnection
Dim rs As SqlDataReader
conn.ConnectionString = ("Data Source=***-PC\SQLEXPRESS;Initial Catalog=Database;Integrated Security=True")
conn.Open()
Try
password = Login.password
Acc_no = SignUp.Account_no
Dim com As New SqlCommand
If password = Login.password Then
com.CommandText = "Select account_no, First_name, Last_name from Table WHERE pasword = '" & password & "'"
com.Connection = conn
rs = com.ExecuteReader
While rs.Read
Me.lblaccno.Text = Convert.ToDouble(rs("account_no"))
Me.lblname.Text = Convert.ToString(rs("First_name")) & " " & Convert.ToString(rs("Last_name"))
Acc_no = lblaccno.Text
End While
ElseIf Acc_no = SignUp.Account_no Then
com.CommandText = "Select account_no, First_name, Last_name from Table WHERE account_no ='" & Acc_no & "'"
com.Connection = conn
rs = com.ExecuteReader
While rs.Read
Me.lblaccno.Text = Convert.ToDouble(rs("account_no"))
Me.lblname.Text = Convert.ToString(rs("First_name")) & " " & Convert.ToString(rs("Last_name"))
Acc_no = lblaccno.Text
End While
End If
Catch ex As Exception
MsgBox("ERROR: " & ex.Message.ToString())
End Try