CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2008
    Posts
    142

    Stored Procedures

    i m writting an application in which i add,delete and edit the records
    i m using sql server
    i have one table called Contacts in the database and few stored procedures in the database
    i have method RetreiveContacts()
    Code:
    Private Sub RetrieveContacts()
            Dim conn As New SqlConnection(My.Settings.AddressBookConnection)
            Dim adapter As New SqlDataAdapter("Contacts_AllContacts_Select", conn)
            Dim dt As New DataTable("Contacts")
            adapter.Fill(dt)
            dgContacts.DataSource = dt
        End Sub
    when i run my project ...error comes on following line
    Code:
     adapter.Fill(dt)
    and error says"Could not find stored procedure 'Contacts_AllContacts_Select'"
    but i have added this stored procedure into the database
    i m attaching code and database files,kindly tell me the solution
    thanks
    Attached Files Attached Files

  2. #2
    Join Date
    Dec 2003
    Location
    Northern Ireland
    Posts
    1,362

    Re: Stored Procedures

    Maybe you need a 'CALL' before your procedure name.

    i.e Dim adapter As New SqlDataAdapter("CALL Contacts_AllContacts_Select", conn)

    Thats the way it is in MySQL.

    Does it work from enterprise manager?
    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook


    0100 1101 0110 1001 0110 0011 0110 1000 0110 0001 0110 0101 0110 1100 0010 0000 0100 0101 0110 1100 0110 1100 0110 0101 0111 0010

  3. #3
    Join Date
    Dec 2007
    Location
    South Africa
    Posts
    263

    Re: Stored Procedures

    I will look at your Project Tomorow when i get to the Office. now i need to ask you some few questions about what i see in your Code

    The SP "Contacts_AllContacts_Select", Who owns the Sp, For an Exampel , if you call a SP that is Owned by the different user just like that , well SQL is supposed to tell you that the SP does not Exists. try to put a User of the SP like this

    Code:
    dbo.Contacts_AllContacts_Select
    To fid out who is the Owner of the SP, in your management Studio , Go to Database, digg below Programibility and choose the StoredProcedure and in the StoredProcedure, look for you Sp "Contacts_AllContacts_Select", Check the Prefix of the SP. If i helped rate me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured