b0b080698
asked on
Calling SQL Server Stored Procedures using DAO
I'm trying to call a stored procedure using DAO on a SQL server. I've seen and tried examples for RDO but i don't know what that is and i can't get it to work either.
I have no problems sending queries using OpenRecordset and getting the results that way, so i know i'm connecting properly.
I need a detailed description of how to connect to a SQL server database, call a stored procedure and have it return results to me. i also need to be able to send data to the stored procedure that updates records and doesnt return results. and even more if the stored procedure is made to send an error message if something happens i need it to be able to send that back to me rather then the 'ODBC -- connection failed' error.
thanx!
I have no problems sending queries using OpenRecordset and getting the results that way, so i know i'm connecting properly.
I need a detailed description of how to connect to a SQL server database, call a stored procedure and have it return results to me. i also need to be able to send data to the stored procedure that updates records and doesnt return results. and even more if the stored procedure is made to send an error message if something happens i need it to be able to send that back to me rather then the 'ODBC -- connection failed' error.
thanx!
ASKER
thanx. that seems to have worked. but i need a little more power then just retreiving record sets. how do i make it so that i can send values to the the stored procedure? how can i make it so that if the stored procedure dies i get the stored procedure error rather then just the 'ODBC -- connection failed error.'?
i think i'll ammend my question up top.
i think i'll ammend my question up top.
ASKER
Adjusted points to 150
ASKER
Edited text of question
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanx.
i got the error thing figured out. i wrote a stored procedure that purpously produced an error. i didnt have an error handler so the only thing i ever got was 'ODBC -- connection failed' which isnt really what happend because the connection worked fine. it executed the procedure got the error and kicked out. oh well. i think i'll be fine from here. thanx! :P
i got the error thing figured out. i wrote a stored procedure that purpously produced an error. i didnt have an error handler so the only thing i ever got was 'ODBC -- connection failed' which isnt really what happend because the connection worked fine. it executed the procedure got the error and kicked out. oh well. i think i'll be fine from here. thanx! :P
No problem - if you've got any further problems that you can always drop me a line (peterjwest@yahoo.com)
Cheers
Pete
Cheers
Pete
You say that standard queries work ok? Well, rather than going through all the routine of explaining how to connect i'll try to give you some ideas as to why your stored procedures aren't working - if you're still having problems after checking these things then i'll be only too happy to explain connection issues, including RDO if necessary.
You can call a stored procedure in exactly the same way as you'd execute a normal query - for example, if you had a stored procedures called MyQuery you would simply do the following:
Set MyData = db.OpenRecordset("MyQuery"
The above line will return a read-only recordset although you could change it to a read/write data set by simply using dbOpenDynaSet instead of dbOpenSnapShot. We ALWAYS use dbSQLPassThrough at the place where I work when executing any queries on SQL Server.
Finally you'll need to make sure you've got priviledges to execute the stored procedure. These rights will need allocating to the username you use to access the database tables.
Hope this gives you some ideas, let me know if you want to know anything else - i'm quite new to SQL Server myself but my colleague is something of an expert on it....
Pete