I’m using some stored procedures in an ASP.Net page. I often use either the row number or the name of the row between quotes, but I can’t find a way to access inner-joined tables by name:
Dim conn As New SqlConnection("my_connection_string")
Dim mycommand As New SqlCommand("last_played_songs", conn)
mycommand.CommandType = CommandType.StoredProcedure
mycommand.Parameters.AddWithValue("@userid", userid)
conn.Open()
Dim dr As SqlDataReader = mycommand.ExecuteReader()
While dr.Read()
/* What I have: */
Dim artist_image As String = dr(39) & "" & "/cover.jpg"
/* What I want. Let's say I called my table ArtistProfile under inner join: */
Dim artist_image As String = dr("ArtistProfile.uniqueID") & "/cover.jpg"
End While
It seems that using the name used with inner join is not the good syntax, but I can’t find how to name it in order to be able to access ‘inner-joined’ tables. The problem with numeric index is that if one of the 4-5 joined tables structure change, all indexes are changing.
Alias the field names in the stored procedure to get this desired output
The default name of the column is the fieldname itself, so in your example it should be just dr(“uniqueID”)