Calling Stored Procedures from VBA Made Easy?
Hello! My thread title says what I've been looking for. I've seen lots of little bits that have fragments of code in VBA, but I have yet to see a cookbook approach that gives me what I need.I have a stored procedure on my SQL Server 2008R2 system that looks like this:
ALTER proc [dbo].[FindZipInfo]
@ZipIn varchar(10),
@City varchar(20) OUTPUT,
@State varchar (10) OUTPUT,
@Country varchar (16) OUTPUT,
@RecordCount integer OUTPUT
as
SELECT @city = city,@State = state,@Country = country FROM tbl_zipcode WHERE zipcode = @ZipIn
set @recordcount = @@ROWCOUNT
I want to call it from my Access 2010 project's VBA code. I have not found a generic outline of what needs to happen, although I have found many short procedure fragments that I don't have the smarts to pull together into something useful and informative for myself.
I've seen some code that just uses a connection, some that wants a command object, and some that uses a recordset, some differing ways of using parameters (in and output), and I'm not sure that I've uncovered the method (ha ha) behind the madness. Sometimes it feels as though I don't even know enough to be dangerous. Maybe that's really VERY dangerous...
I'm trying to use ADO to do all this. The code would be marvelously helpful, but if you could include some references where the concepts are covered, so I can understand how to feed myself from now on, that would be "wonderfuler."
Thanks!
Duff
|