Dim sqlConn As SqlClient.SqlConnection
Dim sqlCmd As SqlClient.SqlCommand
Dim strConnection As String
'Get connection string from App.Config (Must import system.configuration and add reference system configuration
strConnection = ConfigurationManager.ConnectionStrings("hoh_schoolwear_v1._0.My.MySettings.pitl_hoh_schoolwear").ConnectionString
sqlConn = New SqlConnection(strConnection)
sqlCmd = New SqlCommand("Select * FROM tbl_users WHERE username ='" & txtUsername.Text & "'", sqlConn)
sqlConn.Open()
Dim dr As SqlClient.SqlDataReader
dr = sqlCmd .ExecuteReader
While dr.Read()
txtEmail.Text = dr("email")
txtUsername.Text = dr("username")
...
End While
Catch
End Try
dr.Close()
sqlCon.Close()
|