Invalid object name problem

F

Frank Py

I'm getting the following error when trying an example app:
Invalid object name 'Products'.
Exception Details: System.Data.SqlClient.SqlException: Invalid object
name 'Products'.
Line 22: myCommand.Fill(ds)

Help appreciated. Thanks - Frank

<code>

<%@ Page Language="VB" autoeventwireup="false" Debug="true" %>

<%@ import Namespace="System.Data" %>

<%@ import Namespace="System.Data.SqlClient" %>

<%@ import Namespace="System.Drawing" %>
<script runat="server">

Sub Page_Load(Sender As Object, E As EventArgs) Handles MyBase.Load

' TODO: Update the ConnectionString and CommandText values
for your application

Dim ConnectionString As String =
ConfigurationSettings.AppSettings("connectionStringNW")

Dim CommandText As String = "Select CASE WHEN
(Grouping(CategoryName)=1) THEN 'MainTotal' ELSE categoryname END AS
CategoryName, "

CommandText += " CASE WHEN (Grouping(ProductName)=1) THEN
'SubTotal' ELSE Productname END AS ProductName,"

CommandText += " Sum(UnitPrice) as unitprice, "

CommandText += " Sum(UnitsinStock) as UnitsinStock "

CommandText += " from Products INNER JOIN Categories On
Products.categoryID = Categories.CategoryID"

CommandText += " Group By Categoryname, ProductName WITh
ROLLUP "

Dim myConnection As New SqlConnection(ConnectionString)

Dim myCommand As New SqlDataAdapter(CommandText,
myConnection)

Dim ds As New DataSet

myCommand.Fill(ds)

</code>

Thanks
 
J

Jazper

in this case i'm pretty sure your SQL must be wrong.
probably the table Products isn't there anymore or renamed or something
else.
cheers jazper
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top