Public Function GetAuthorsLastNames() As List(Of String)
Dim conn As SqlConnection
Dim cmd As SqlCommand
Dim result As New List(Of String)
Dim cmdString As String = "Select au_lname from authors"
'update this to match the location of pubs on your computer
conn = New SqlConnection("Server=.\SQLEXPRESS;" &
"Database=pubs;" &
"Integrated Security=True;")
cmd = New SqlCommand(cmdString, conn)
conn.Open()
Dim myReader As SqlDataReader
myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
While myReader.Read()
result.Add(myReader("au_lname").ToString())
End While
Return result
End Function
Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;
Dim conn As SqlConnection
Dim cmd As SqlCommand
Dim result As New List(Of String)
Dim cmdString As String = "Select au_lname from authors"
'update this to match the location of pubs on your computer
conn = New SqlConnection("Server=.\SQLEXPRESS;" &
"Database=pubs;" &
"Integrated Security=True;")
cmd = New SqlCommand(cmdString, conn)
conn.Open()
Dim myReader As SqlDataReader
myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
While myReader.Read()
result.Add(myReader("au_lname").ToString())
End While
Return result
End Function
Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;
No comments:
Post a Comment