Solved

error executing store procedure

Posted on 2006-11-10
1
1,581 Views
Last Modified: 2008-01-09
I need to insert all user name for table A into aspnet_membership table. I have to user stored procedure. this is what have so far but it complains about syntax at *** see below.  
--------------------------------------------------------------------
select  UserName into #tmpU from  Rams.dbo.tt_users
select * from #tmpU
 
Declare @cnt int
 
Set @cnt = 0

while @Cnt < (Select count(*) from #tmpU)
Begin
             

   EXEC       [dbo].[aspnet_membership_createuser]
 *** @UserName = #tmpU.UserName, @Password = 'mypassword' +  Convert(varchar(3000),@Cnt)),
      @PasswordSale = null,@Email = #tmpU.UserName,@PasswordQuestion='mypassword',
      @PasswordAnswer='mypassword',@IsApproved = 0,@CurrentTimeUtc=GetDate(), @CreateDate= null,@UniqueEmail=#tmpU.UserName,
      @PasswordFormat= null

End
----------------------------------------------------------------------
I cannot figure out what is the problem. I was passing values with setting @UserName etc but still have same issu.

appreciate it
-kushpaw
0
Comment
Question by:kushpaw
1 Comment
 
LVL 29

Accepted Solution

by:
Nightman earned 125 total points
ID: 17918277
If this is for MSSQL, try the following:


Declare @cnt int
Declare @username varchar(20)
Declare @MyPassword varchar(20)
Declare @Datestamp datetime
Set @cnt = 0
DECLARE tCursor CURSOR fast_forward
FOR
  SELECT
    UserName
  FROM
    Rams.dbo.tt_users
FOR READ ONLY
OPEN tCursor
FETCH next from tCursor into @username
WHILE @@FETCH_STATUS = 0
BEGIN
  set @cnt=@cnt+1
  set @MyPassword='mypassword' +  Convert(varchar(3000),@Cnt)
  set @Datestamp=getdate()
   EXEC      [dbo].[aspnet_membership_createuser]
      @UserName = @username,
      @Password = @MyPassword,
      @PasswordSale = null,
      @Email = @username,
      @PasswordQuestion='mypassword',
      @PasswordAnswer='mypassword',
      @IsApproved = 0,
      @CurrentTimeUtc = @Datestamp,
      @CreateDate = null,
      @UniqueEmail = @username,
      @PasswordFormat = null

FETCH NEXT FROM tCursor INTO @username
END
CLOSE tCursor
DEALLOCATE tCursor
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question