Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pulling an array out of my own namespace?

Status
Not open for further replies.

pha2er

Programmer
Dec 4, 2001
16
GB
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.
 
Hi Pha2er

The 'Expression does not produce a value' because the sub 'consoles' does not return anything.

You have two choices either make the sub return the array or just return the datareader object directly and bind this to yconsoles.

Unfortunately im not a VB.NET developer so im not sure of exact syntax. I know in VB you would return a value by setting the sub to the retun value with a line something like... consoles = consoleList

I dont knwo if this is the same in VB.NET or wether ithas converted to the same syntax as C# where this would be achieved by.... return consoleList.

In either case you will probably have to set a return type for the sub..

hope this helps, sorry i can't give exact syntax but this should set you on the right path...

Rob



------------------------------------

On with the dance! let joy be unconfined;
No sleep till morn, when Youth and Pleasure meet
To chase the glowing hours with flying feet.
-Byron

------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top