01.
Sub
ShowName()
02.
Dim
objconn
As
SqlConnection
03.
Dim
objcmd
As
SqlCommand
04.
Dim
objReader
As
SqlDataReader
05.
Dim
strconn
As
String
06.
Dim
strcmd
As
String
07.
08.
09.
10.
strconn = ConfigurationManager.AppSettings(
"ConnectionString"
)
11.
objconn =
New
SqlConnection(strconn)
12.
objconn.Open()
13.
14.
15.
strcmd =
"select ID,NAME,LASTNAME from USERS"
16.
17.
objcmd =
New
SqlCommand(strcmd, objconn)
18.
objReader = objcmd.ExecuteReader()
19.
20.
While
objReader.Read()
21.
ddlcostcen.Items.Add(
New
ListItem(
String
.Format(
"{0} {1} {2}"
, objReader(
"ID"
).ToString(), objReader(
"NAME"
).ToString(), objReader(
"LASTNAME"
).ToString()), objReader(
"ID"
).ToString()))
22.
End
While
23.
24.
objconn.Close()
25.
End
Sub