Having an issue passing some information between forms.
On a login form, I passed and Employee ID number to a hidden label on the next form (form1).
And it shows up if I remove the hide label.
I am trying to using the employee id number I passed to that hidden label, to pull First and Last name from that database table, and pass it concatenated to Label2 on this form.
Executing my code I am getting a SQL Exception "Could not find stored procedure False" when it gets to the ExecuteReader method.
The Table I am pulling info from is as follows...
Column1 id, Column 2 EmpID, Column 3 FirstName, Column 4 Lastname, Column 5 password, Column 6 Admin (0 - 1 to denote a user or admin)
My code for Form1 so far is...
Thanks in Advance
On a login form, I passed and Employee ID number to a hidden label on the next form (form1).
And it shows up if I remove the hide label.
I am trying to using the employee id number I passed to that hidden label, to pull First and Last name from that database table, and pass it concatenated to Label2 on this form.
Executing my code I am getting a SQL Exception "Could not find stored procedure False" when it gets to the ExecuteReader method.
The Table I am pulling info from is as follows...
Column1 id, Column 2 EmpID, Column 3 FirstName, Column 4 Lastname, Column 5 password, Column 6 Admin (0 - 1 to denote a user or admin)
My code for Form1 so far is...
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports System.Windows.Forms
Imports System.Windows.Forms.Form
Imports System.Windows.Forms.Label
Imports System.Windows.Forms.TextBox
Public Class Form1
Public Sub Form1toLabel(ByVal Txt As String)
Label1.Text = Txt
Label1.Hide()
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim dbFirstName As String
Dim dbLastName As String
Dim EmpID1 As String
EmpID1 = Label1.Text
Using connObj As New SqlClient.SqlConnection("server=SQL01;database=Emp_App;uid=sa;pwd=password;")
Using cmdObj As New SqlClient.SqlCommand("select FirstName, LastName from Emp_Employees where EmpID" = EmpID1, connObj)
connObj.Open()
Using readerObj As SqlClient.SqlDataReader = cmdObj.ExecuteReader ' Here is my thrown error
'This will loop through all returned records
While readerObj.Read
dbFirstName = readerObj("FirstName").ToString
dbLastName = readerObj("LastName").ToString
'handle returned value before next loop here
Label2.Text = String.Concat(dbFirstName, " ", dbLastName)
End While
End Using
connObj.Close()
End Using
End Using
End Sub
End Class
Thanks in Advance
Last edited by a moderator: