JWColby
jwcolby at colbyconsulting.com
Thu May 3 23:44:38 CDT 2007
Eric, >http://www.tek-tips.com/viewthread.cfm?qid=1362565&page=1 This code does not work for my purposes. Probably because I am not returning a recordset. I cut and pasted it in and fixed up the pieces but ended up with a "multistep process not completed. No work done" error message on the last step: GetADoRSP.Open... If I can get this part working I am golden! Thanks for your assistance in all this. John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Eric Barro Sent: Thursday, May 03, 2007 6:30 PM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Calling a stored procedure from Access John, Here's how I created the bulk insert statement for my application... ALTER PROCEDURE dbo.ImportEmployeesFromPeopleSoft @DataFileName varchar(255), @ImportFormatFileName varchar(255) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; DECLARE @sql varchar(1000) -- Create a table to hold the data CREATE TABLE #tmpEmployees ( suffix varchar(5), last_name varchar(30), first_name varchar(20), ...the rest of your fields go in here ) -- Read the text file into the temp table SET @sql ='BULK INSERT #tmpEmployees FROM ' + CHAR(39) + @DataFileName + CHAR(39) SET @sql = @sql + ' WITH (FORMATFILE = ' + CHAR(39) + @ImportFormatFileName + CHAR(39) + ')' EXEC (@sql) -- Remove the records from the Employees table first --NOTE: truncate bypasses transaction log but it is the fastest way to clear a table and reset identity fields; use DELETE FROM if you want to recover using t-log TRUNCATE TABLE Employees -- insert the records into the Employees table INSERT INTO Employees SELECT RTRIM(suffix) as suffix, RTRIM(last_name) as last_name, RTRIM(first_name) as first_name, ...the rest of your fields go in here FROM #tmpEmployees -- And then clean up DROP TABLE #tmpEmployees END Here's a link that shows how to call the sproc using ADO via Access. http://www.tek-tips.com/viewthread.cfm?qid=1362565&page=1 --Eric