AznCutie
Member
Im not sure whats erroring out, and I dont know whats wrong. Basically, Ive got a sub that loads pictures into a datalist, and they link to a specific category. link. I dont know why its erroring out at this area, but I have a feeling its got something to do with the data adapter.
Here is the sub for the selection of the categories
And heres the code for the datalist control:
Any ideas would be greatly appreciated.
Here is the sub for the selection of the categories
Code:
Private Sub Page_Load(sender as object, e as eventargs)
Dim objCN as OleDbConnection Database Connection object
Dim objDA as OleDbDataAdapter Database Adaptor object
Dim objDS as DataSet Dataset object
Dim objCM as OleDbCommand
Dim strSQL as String
Dim strCN as String
Dim intSelection As Integer = CInt(Request.QueryString("selection"))
If Not IsPostBack Then
strCN = "PROVIDER = Microsoft.Jet.OLEDB.4.0;" & _
"DATA SOURCE=" & Server.MapPath("./db/datastore.mdb" )
objCN = New OleDbConnection( strCN )
objCN.Open()
If (intSelection=0) Then
strSQL = "SELECT * FROM (tblProduct LEFT JOIN tblCategory on tblProduct.ProdCat=tblCategory.CategoryID) WHERE Category=Stainless "
Else if (intSelection=1) Then
strSQL = "SELECT * FROM (tblProduct LEFT JOIN tblCategory on tblProduct.ProdCat=tblCategory.CategoryID) WHERE Category=Specialty "
else if (intSelection=2) Then
strSQL = "SELECT * FROM (tblProduct LEFT JOIN tblCategory on tblProduct.ProdCat=tblCategory.CategoryID) WHERE Category=Lefty"
else if (intSelection=3) Then
strSQL = "SELECT * FROM (tblProduct LEFT JOIN tblCategory on tblProduct.ProdCat=tblCategory.CategoryID) WHERE Category=Clipper "
else if (intSelection=4) Then
strSQL = "SELECT * FROM (tblProduct LEFT JOIN tblCategory on tblProduct.ProdCat=tblCategory.CategoryID) WHERE Category=Iron "
else if (intSelection=5) Then
strSQL = "SELECT * FROM (tblProduct LEFT JOIN tblCategory on tblProduct.ProdCat=tblCategory.CategoryID) WHERE Category=Custom "
else if (intSelection=6) Then
strSQL = "SELECT * FROM (tblProduct LEFT JOIN tblCategory on tblProduct.ProdCat=tblCategory.CategoryID) WHERE Category=Comb "
else if (intSelection=7) Then
strSQL = "SELECT * FROM (tblProduct LEFT JOIN tblCategory on tblProduct.ProdCat=tblCategory.CategoryID) WHERE Category=Cobalt "
else if (intSelection=8) Then
strSQL = "SELECT * FROM (tblProduct LEFT JOIN tblCategory on tblProduct.ProdCat=tblCategory.CategoryID) WHERE Category=Dryer "
else
strSQL="SELECT * from tblProduct"
End IF
objDA = New OleDbDataAdapter( strSQL, objCN )
objDS = New DataSet
objDA.Fill (objDS, "tblProduct")
objCN.Close()
ProductList.DataSource=objDS.Tables("tblProduct").DefaultView
ProductList.DataBind()
End If
End Sub
And heres the code for the datalist control:
Code:
<asp:datalist id="ProductList" repeatcolumns="3" repeatdirection="horizontal" runat="server">
<Itemtemplate> <IMG height="80" width="220" SRC=./images/<%# Container.DataItem("ImageAddress") %> ><br><%# Container.DataItem("ProdName") %>
</itemtemplate>
<selecteditemtemplate> </selecteditemtemplate>
</asp:datalist>
Any ideas would be greatly appreciated.