Hello ,
je reviens vers vous pour solliciter vos connaissances..
mon problème est le suivant : Je recupère le login du client et ensuite je fais une requete vers un DB SQL pour avoir le nom complet correspondant a ce login et affiche le tout dans un label .. tout cela dans le pageload sub ..
Seulement le truc c'est que le nom s'affiche seulement après un page refresh (F5) .. et je ne comprends pas pourquoi .. si je remplace le contenu du label par un string tout con genre "test" il n'y pas de soucis..
quelqu'un aurait une soluce ?
voici le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108 Imports System Imports System.Web Imports System.Web.SessionState Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.HtmlControls Imports System.Collections Imports System.Configuration Imports System.Data Imports System.Data.SqlClient Imports System.Drawing Imports Microsoft.Visualbasic Imports System.Web.Mail Namespace System.Data.SqlTypes End Namespace Namespace SendMail End Namespace Public Class cambio Inherits System.Web.UI.Page Protected WithEvents lblpickupDate As System.Web.UI.WebControls.label Protected WithEvents pickupLocation As System.Web.UI.WebControls.DropDownList Protected WithEvents lblbringInDate As System.Web.UI.WebControls.Label Protected WithEvents sofwares As System.Web.UI.WebControls.TextBox Protected WithEvents chk_sofwares As System.Web.UI.WebControls.CheckBox Protected WithEvents chk_otherDate As System.Web.UI.WebControls.CheckBox Protected WithEvents wich_soft As System.Web.UI.WebControls.TableCell Protected WithEvents choose_oth_date As System.Web.UI.WebControls.Label Protected WithEvents lbllogon As System.Web.UI.WebControls.Label Protected WithEvents otherdate As System.Web.UI.WebControls.Textbox Protected WithEvents reason4otherdate As System.Web.UI.WebControls.Label Protected WithEvents other_date As System.Web.UI.WebControls.Textbox Protected WithEvents img_calendar As System.Web.UI.HtmlControls.HtmlImage 'Executed on page load Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim name As String 'Only execute the first time the page loads (performance) 'get the logon informations name = Request.ServerVariables("LOGON_USER") name = UCase(TrimStartStr(name, "NTCH01\")) Dim connection As New SqlConnection() 'get the connection infos from webconfig connection.ConnectionString = ConfigurationSettings.AppSettings("sqlServer") 'build the query Dim strClientName As String Dim s As String = "SELECT [Client Name] FROM dbo.MasterData WHERE Login = '" s = s & name s = s & "'" 'Execute the query Dim myCommand As New SqlCommand(s, connection) connection.Open() Dim myReader As SqlDataReader myReader = myCommand.ExecuteReader() 'Enter the query data into session variables and then redirect to the actual page to create a new RO While myReader.Read() Try strClientName = myReader("Client Name") Catch myReader.Close() connection.Close() End Try End While If len(strClientName) <> 0 Then name = strClientName lbllogon.text = name End If 'lbllogon.text = "Test" lbllogon.Visible = True myReader.Close() connection.Close() End Sub
merci d'avance..
Partager