vs 2010 WinForm, c#, spProducts not found

Posted on 2013-11-02
Medium Priority
Last Modified: 2013-11-03
At line 45 da.Fill(ds); the attached code errors: Cannot find the stored procedure

Using straight Select * From Products, this code works fine (meaning there is no connection issue to the database) and the store procedure exists in the database (it has been tested in SSMS).

Question: Why this could cannot find spProducts?

Thank you.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using System.Data.SqlClient;

namespace ado01_Connection
    public partial class Form10 : Form
        public Form10()

        private void Form10_Load(object sender, EventArgs e)
            //string cs = ConfigurationManager.ConnectionStrings["csDatabase"].ConnectionString;
            //SqlConnection con = new SqlConnection(cs);
            //using (con)
            //    SqlDataAdapter da = new SqlDataAdapter("SELECT [CategoryName],[Description],[Picture] FROM [Northwind].[dbo].[Categories];", con);
            //    DataSet ds = new DataSet();
            //    da.Fill(ds);
            //    gwCategory.DataSource = ds.Tables[0];

        private void button1_Click(object sender, EventArgs e)
            string cs = ConfigurationManager.ConnectionStrings["csDatabase"].ConnectionString;
            SqlConnection con = new SqlConnection(cs);
            DataSet ds = new DataSet();
            using (con)
                SqlDataAdapter da = new SqlDataAdapter("spProducts;", con);
                da.SelectCommand.CommandType = CommandType.StoredProcedure;
                da.SelectCommand.Parameters.AddWithValue("@CategoryID", "5");//txtCategoryId.Text);
                gwCategory.DataSource = ds.Tables[0];

Open in new window

Question by:Mike Eghtebas
LVL 35

Accepted Solution

Robert Schutt earned 2000 total points
ID: 39619630
Not sure if that will be the final solution but start with removing the semicolon after the stored procedure name.
SqlDataAdapter da = new SqlDataAdapter("spProducts;", con);

Open in new window

probably just need:
SqlDataAdapter da = new SqlDataAdapter("spProducts", con);

Open in new window

LVL 34

Author Closing Comment

by:Mike Eghtebas
ID: 39619873
Thank you.

Featured Post

7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

SingleRun is a tool that ensures that only one instance of an application is started, running it again brings the application to focus.
This article describes and provides a custom-made tool I wrote to give businesses a means of identifying commercial music content, without having to expend too much effort. Business recordings are easily identified from possibly illegal music files …
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
To export Lotus Notes to Outlook PST or Exchange and Domino Server files to Exchange Server or PST files with ease, go for Kernel for Lotus Notes to Outlook conversion tool. Through the video, you can watch the conversion process. A common user with…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question