I have two forms a login form and a information form....How i have it now u use your firstname as username and lastname as password...Then I want Form2 to take the firstname and the lastname u use to login and run that cmd and send that information to those txtcontrols....When i hardcode some strings and assign those to the where the login txtcontrols go it works from but when i have login.TextBox1.Text it does nothing....any help on this
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim login As Form1 = New Form1()
Dim str As String = System.Configuration.ConfigurationManager.AppSettings("conn")
Dim Sqlconnect As SqlConnection = New SqlConnection(str)
Dim cmd As String = "Select * From Employees Where FirstName = '" & login.TextBox1.Text & "' And LastName = '" & login.TextBox2.Text & "'"
Dim sqlcmd As SqlCommand = New SqlCommand(cmd, Sqlconnect)
Dim dr As SqlDataReader
Dim fname As String = ""
Dim lname As String = ""
Dim fullname As String = ""
Dim position As String = ""
Dim notes As String = ""
Dim address As String = ""
Dim city As String = ""
Dim phonenumber As String = ""
Sqlconnect.Open()
dr = sqlcmd.ExecuteReader()
While dr.Read
fname = dr.Item( "FirstName").ToString()
lname = dr.Item( "LastName").ToString()
position = dr.Item( "Title").ToString()
notes = dr.Item( "Notes").ToString()
address = dr.Item( "Address").ToString()
city = dr.Item( "City").ToString()
phonenumber = dr.Item( "HomePhone").ToString()
fullname = fname + " " + lname
Me.txtemployee.Text = fullname
Me.txtaddress.Text = address
Me.txtposition.Text = position
Me.txtphone.Text = phonenumber
Me.txtcity.Text = city
Me.txtnotes.Text = notes
End While
End Sub
Visual Basic4
|