[Resolved] E_FAIL on cmd.ExecuteReader()????
IErrorInfo.GetDescription failed with E_FAIL(0x80004005).
Whats that mean?
Quote:
objConn.Open()
Line 22: cmdSelect= New OleDbCommand("SELECT Catalog.CatID, Catalog.Name, Product.ProductID, Product.Name AS ProductName, Product.Price, Product.OfferQty, Product.OfferPrice FROM tbl_catalog AS Catalog, tbl_products AS Product WHERE Catalog.CatID = Product.CategoryID ORDER BY Catalog.Name ASC", objConn)
Line 23: dtrReader= cmdSelect.ExecuteReader()
Re: E_FAIL on cmd.ExecuteReader()????
SELECT Catalog.CatID, Catalog.Name, Product.ProductID, Product.Name AS ProductName, Product.Price, Product.OfferQty, Product.OfferPrice
FROM tbl_catalog AS Catalog, tbl_products AS Product
WHERE Catalog.CatID = Product.CategoryID
ORDER BY Catalog.Name ASC
Does this statement work if you use this in the database/ in a test outside of your project. It maybe you need to use a JOIN statement (!LEFT JOIN", "INNER JOIN" or "OUTER JOIN") to link these tables to get the information...
Re: E_FAIL on cmd.ExecuteReader()????
Yes, If i were to open up a new query in Access and use that SQL statement it pulls the data set fine. I dont see why I couldn't do a simple join, (i.e. WHERE TableA.Field1 = TableB.Field1)
This is my first time messing with ASP.NET btw.
Here is my code:
Quote:
Sub Page_Load
Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0; DATA Source=\\somepath\db.mdb;"
Dim objConn As OleDbConnection
Dim cmdSelect As OleDbCommand
Dim dtrReader As OleDbDataReader
objConn = New OleDbConnection(connString)
cmdSelect = New OleDbCommand("SELECT Catalog.CatID, Catalog.Name AS CatalogName, Product.ProductID, Product.Name AS ProductName, Product.Price, Product.OfferQty, Product.OfferPrice FROM tbl_catalog AS Catalog INNER JOIN tbl_products AS Product ON Catalog.CatID = Product.CategoryID ORDER BY Catalog.Name, Product.Name ASC", objConn)
objConn.Open()
dtrReader = cmdSelect.ExecuteReader(CommandBehavior.CloseConnection)
dgProducts.DataSource = dtrReader
dgProducts.DataBind()
dtrReader.Close()
End Sub
</script>
<asp:DataGrid id="dgProducts" runat="server"
AutoGenerateColumns="False" CellPadding="4"
HeaderStyle-BackColor="Black"
HeaderStyle-ForeColor="White"
HeaderStyle-HorizontalAlign="Center"
HeaderStyle-Font-Bold="True">
<Columns>
<asp:BoundColumn HeaderText="Cat" DataField="CatalogName" />
<asp:BoundColumn HeaderText="Product" DataField="ProductName" />
<asp:BoundColumn HeaderText="Price" DataField="ProductPrice" />
<asp:BoundColumn HeaderText="Offer Qty" DataField="ProductOfferQty" />
<asp:BoundColumn HeaderText="Offer Price" DataField="ProductOfferPrice" />
<asp:BoundColumn HeaderText="Product #" DataField="ProductID" />
</Columns>
</asp:DataGrid>
EDITD: Ok the code above uses an INNER JOIN but it still doesnt work. Works in Access but not on the website.
Re: E_FAIL on cmd.ExecuteReader()????
Oh and btw.. I can access the database with that SQL statement just fine with ASP, just not with ASP.NET
Re: E_FAIL on cmd.ExecuteReader()????
This thread is RESOVED!!!!
Microsoft can go shove it. Why can't they make better error reporting?
Note to self 'Catalog' is a freaking reserved keyword.