Click to See Complete Forum and Search --> : Type not defined error


adonweb
05-12-2008, 08:08 AM
I am trying to display the products from sql server database. But when i try to access the page, i get the error.

BC30002: Type 'products.getproducts' is not defined

my vb code is successfully compiled to dll. Wht i am doing wrong? Please help me. I searched on msdn and google, couldnt find proper solution.

' VB Document
Imports System
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Namespace products
Public Class getproducts
Public Function getallproducts() as SqlDataReader
Dim mycon as SqlConnection=New SqlConnection ("database=databasename;server=servername;uid=xxx;password=xxx")
Dim mycommand as SqlCommand=New SqlCommand("select * from categories",mycon)
Dim reader as SqlDataReader
mycon.Open()
Return mycommand.ExecuteReader(CommandBehavior.CloseConnection)
End Function
End Class
End Namespace


Here is my aspx page..

<script language="vb" runat="server">
Sub Page_Load(sender as Object,e as EventArgs)
loadgrid(grid)
End Sub
Private Sub loadgrid(mydatagrid as System.Web.UI.WebControls.DataGrid)
Dim dat as New products.getproducts()
mydatagrid.DataSource=dat.getallproducts()
mydatagrid.DataBind()
End Sub
</script>
</head>
<body>
<form runat="server" id="frm">
<asp:DataGrid id="grid" runat="server"></asp:DataGrid>
</form>
</body>

chazzy
05-12-2008, 12:30 PM
is this all 1 project inside of visual studio, or separate projects (such as in visual web developer/vb express)

adonweb
05-13-2008, 02:13 AM
Same project...

DarkBob
05-14-2008, 07:46 AM
You could try adding the line <%@ Import Namespace="products" %> below the <%@ Page %> tag.

If this works it means that etiher that products is not defined in the code behind file but in some other dll or that the code behind file is no longer hooked up to the aspx file proerly if this is the case check the <%@ Page %> tag and make sure all the attributes are set up correctly.

If this all sounds like too much work try sitting back and downing cold beers till it isn't a problem any more.