locked
Could not find stored procedure RRS feed

  • Question

  • Hello.
    I am new in .NET programming and I have created a project which stores some words that the Google returns as a result.
    I'm facing the following problem.
    When I try to run the project I get the message "Could not find stored procedure".
    I have created a form (form2.cs) and a code snippet is the following:

    private
     void
     button1_Click(object
     sender, System.EventArgs e)
            {
     
                DataSet ds = m_dsLogging.FromGoogle();
                foreach
    (DataTable myTable in
     ds.Tables)            
                {
                    foreach
     (DataRow myRow in
     myTable.Rows)
                    {
                         MessageBox.Show(Convert.ToString(myRow["title"
    ]));
                         m_dsLogging.IndexedOne(Convert.ToInt32(myRow["id"
    ]));
                         m_dsLogging.IndexContent(Convert.ToInt32(myRow["id"
    ]), Convert.ToString(myRow["title"
    ]), Convert.ToString(myRow["url"
    ]), Convert.ToString(myRow["snippet"
    ]));
                    }
                }
                 MessageBox.Show("Choices Indexing process completed!!!"
    );
            }
    
    
    and at Dataservices.cs file I do the following:

    public
     DataSet FromGoogle()
            {
                    SqlDataAdapter cmd = new
     SqlDataAdapter("FromGoogle"
    , m_cn);
                    cmd.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
               
                    DataSet ds = new
     DataSet();
                    cmd.Fill(ds);
                    return
     (ds);	
            }
    
    When the code reaches the cmd.Fill(ds) point, I get an error "Could not find stored procedure("FromGoogle")".

    System.Data.SqlClient.SqlException was unhandled
      Message="Could not find stored procedure 'FromGoogle'."
      Source=".Net SqlClient Data Provider"
      ErrorCode=-2146232060
      Class=16
      LineNumber=1
      Number=2812
      Procedure=""
      Server="ACER\\SQLEXPRESS"
      State=62
      StackTrace:
           σε System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
           σε System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
           σε System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
           σε System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
           σε System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
           σε System.Data.SqlClient.SqlDataReader.get_MetaData()
           σε System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
           σε System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
           σε System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
           σε System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
           σε System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
           σε System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
           σε System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
           σε System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
           σε System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
           σε System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
      InnerException: 
    


    Can anyone understand what goes wrong ????

    I use VS 2008 Professional Edition and SQL Server Management Studio 2008.
    Saturday, December 26, 2009 3:58 PM

Answers

  • Your code does not find a stored procedure named: "FromGoogle" in the user default schema, or the dbo schema.

    Verify that the database contains a stored procedure named "FromGoogle", and verfiy the schema for that stored procedure.

    IF the stored procedure exists, you may need to change:

       sqlDataAdapter cmd = new SqlDataAdapter("FromGoogle", m_cn);

    to:

        sqlDataAdapter cmd = new SqlDataAdapter("schema.FromGoogle", m_cn);

    Where you replace the work 'schema' with the actual schema name.

    "You cannot do a kindness too soon because you never know how soon it will be too late." -Ralph Waldo Emerson
    Saturday, December 26, 2009 7:54 PM