Hi there,
I'm trying to figure out how to create and use an array in my own namespace, I've got this far, but I'm quite new to asp.net so I'm not sure where to go from here:
Imports System.Data.SqlClient
Namespace GamesExchange
Public Class nameLists
Public Sub consoles()
Dim objConnection As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")
Dim objCommand As SqlCommand = New SqlCommand("SELECT * FROM gx_consoles ORDER BY name", objConnection)
objConnection.Open()
Dim objReader As SqlDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConnection)
Dim consoleList As New ArrayList()
While objReader.Read()
consoleList.Add(objReader("name")
End While
objReader.Close()
End Sub
End Class
End Namespace
I'm trying to target it like this:
Dim objConsoleList As GameExchange.nameLists
yconsole.DataSource() = objConsoleList.consoles
yconsole.DataBind()
This line: 'objConsoleList.consoles' is underlined in blue in VS.NET and tells me this:
"Expression does not produce a value"
What am I doing wrong here?
TIA
G.
I'm trying to figure out how to create and use an array in my own namespace, I've got this far, but I'm quite new to asp.net so I'm not sure where to go from here:
Imports System.Data.SqlClient
Namespace GamesExchange
Public Class nameLists
Public Sub consoles()
Dim objConnection As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")
Dim objCommand As SqlCommand = New SqlCommand("SELECT * FROM gx_consoles ORDER BY name", objConnection)
objConnection.Open()
Dim objReader As SqlDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConnection)
Dim consoleList As New ArrayList()
While objReader.Read()
consoleList.Add(objReader("name")
End While
objReader.Close()
End Sub
End Class
End Namespace
I'm trying to target it like this:
Dim objConsoleList As GameExchange.nameLists
yconsole.DataSource() = objConsoleList.consoles
yconsole.DataBind()
This line: 'objConsoleList.consoles' is underlined in blue in VS.NET and tells me this:
"Expression does not produce a value"
What am I doing wrong here?
TIA
G.