sqlDataSource.InsertParameter type conversion problem

I'm trying to add a parameter to an sqlDataSource from VB code behind.  The parameter value is the MembershipUser.ProviderUserKey.tostring.  I'm getting the following error:

"Implicit conversion from data type nvarchar to varbinary is not allowed. Use the CONVERT function to run this query."

I've tried CAST and CONVERT to no success.
Private Sub CreateUserWizard1_CreatedUser1(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizard1.CreatedUser
        Dim UserNameTextBox As TextBox = CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName")
        Dim DataSource As SqlDataSource = CreateUserWizardStep2.ContentTemplateContainer.FindControl("InsertExtraInfo")
        Dim User As MembershipUser = Membership.GetUser(UserNameTextBox.Text)
        Dim UserGUID As Object = User.ProviderUserKey
        DataSource.InsertParameters("UserId").DefaultValue = UserGUID.ToString
        DataSource.Insert()
    End Sub
 
.........................................................
 
 
   <asp:SqlDataSource ID="InsertExtraInfo" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>" 
                                                InsertCommand="INSERT INTO [UserAddresses] ([UserId], [FirstName], [LastName], [Phone], [ShippingAddress], [ShippingCity], [ShippingState], [ShippingZip]) 
                                                               VALUES (CAST(@UserId AS VARBINARY), @FirstName, @LastName, @Phone, @ShippingAddress, @ShippingCity, @ShippingState, @ShippingZip)"
                                                ProviderName="<%$ ConnectionStrings:ConnectionString2.ProviderName %>">
                                                <InsertParameters>
                                                    <asp:Parameter Name="UserId"/>
                                                    <asp:ControlParameter Name="FirstName" Type="String" ControlID="FirstName" PropertyName="Text" />
                                                    <asp:ControlParameter Name="LastName" Type="String" ControlID="LastName" PropertyName="Text" />
                                                    <asp:ControlParameter Name="Phone" Type="String" ControlID="Phone" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingAddress" Type="String" ControlID="ShippingAddress" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingCity" Type="String" ControlID="ShippingCity" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingState" Type="String" ControlID="ShippingState" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingZip" Type="String" ControlID="ShippingZip" PropertyName="Text" />
                                                </InsertParameters>
                                            </asp:SqlDataSource>

Open in new window

cer_petsafeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

guru_samiCommented:
why do you have  CAST(@UserId AS VARBINARY in your InsertCommand?
What Type is it in the DB?
Change VARBINARY  to Varchar if you want to store string
0
guru_samiCommented:
Also if you are linking it to default membership aspnet_users table ..UserId in your user Profile table should be uniqueidentifier.
Check this for linking aspnet_Users table with another table to store additional user information:

http://www.asp.net/learn/security/tutorial-08-vb.aspx

0
jinalCommented:
what is type in your DB for UserID ?




 <asp:SqlDataSource ID="InsertExtraInfo" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>" 
                                                InsertCommand="INSERT INTO [UserAddresses] ([UserId], [FirstName], [LastName], [Phone], [ShippingAddress], [ShippingCity], [ShippingState], [ShippingZip]) 
                                                               VALUES (CAST(@UserId AS VARBINARY), @FirstName, @LastName, @Phone, @ShippingAddress, @ShippingCity, @ShippingState, @ShippingZip)"
                                                ProviderName="<%$ ConnectionStrings:ConnectionString2.ProviderName %>">
                                                <InsertParameters>
                                                    <asp:Parameter Name="UserId" DbType="Guid"/>
                                                    <asp:ControlParameter Name="FirstName" Type="String" ControlID="FirstName" PropertyName="Text" />
                                                    <asp:ControlParameter Name="LastName" Type="String" ControlID="LastName" PropertyName="Text" />
                                                    <asp:ControlParameter Name="Phone" Type="String" ControlID="Phone" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingAddress" Type="String" ControlID="ShippingAddress" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingCity" Type="String" ControlID="ShippingCity" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingState" Type="String" ControlID="ShippingState" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingZip" Type="String" ControlID="ShippingZip" PropertyName="Text" />
                                                </InsertParameters>
                                            </asp:SqlDataSource>

Open in new window

0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

jinalCommented:

 <asp:SqlDataSource ID="InsertExtraInfo" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>" 
                                                InsertCommand="INSERT INTO [UserAddresses] ([UserId], [FirstName], [LastName], [Phone], [ShippingAddress], [ShippingCity], [ShippingState], [ShippingZip]) 
                                                               VALUES (@UserId, @FirstName, @LastName, @Phone, @ShippingAddress, @ShippingCity, @ShippingState, @ShippingZip)"
                                                ProviderName="<%$ ConnectionStrings:ConnectionString2.ProviderName %>">
                                                <InsertParameters>
                                                    <asp:Parameter Name="UserId" DbType="Guid"/>
                                                    <asp:ControlParameter Name="FirstName" Type="String" ControlID="FirstName" PropertyName="Text" />
                                                    <asp:ControlParameter Name="LastName" Type="String" ControlID="LastName" PropertyName="Text" />
                                                    <asp:ControlParameter Name="Phone" Type="String" ControlID="Phone" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingAddress" Type="String" ControlID="ShippingAddress" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingCity" Type="String" ControlID="ShippingCity" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingState" Type="String" ControlID="ShippingState" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingZip" Type="String" ControlID="ShippingZip" PropertyName="Text" />
                                                </InsertParameters>
                                            </asp:SqlDataSource>

Open in new window

0
cer_petsafeAuthor Commented:
the type in the DB is uniqueidentifier.  I've tried  DbType="Guid" or Type="Object", still no luck!
0
jinalCommented:
<asp:Parameter Name="UserId" DbType="Guid" Type="String"/>

0
cer_petsafeAuthor Commented:
Error: "The Type property of parameter 'UserId' cannot be set when the DbType property is set."
0
guru_samiCommented:
This is what you should be doing:
1: Remove this <asp:Parameter Name="UserId" DbType="Guid"/> from your    <InsertParameters>
2:Then adjust your code behind like below:
        Dim UserGUID As Stiring = User.ProviderUserKey.ToString
        DataSource.InsertParameters.Add("UserId", DbType.Guid, UserGUID)
        DataSource.Insert()

                                                 
0
cer_petsafeAuthor Commented:
sorry guru_sami,  

I still get the original data type conversion error.  I started with code very similar to that and switch hoping it would work.  But it really does the same thing, just in different order.  
0
guru_samiCommented:
alrite how about posting your current complete code here once again.
0
cer_petsafeAuthor Commented:
There must be something else at play here, because stepping through the code, everything works right up the insert().  Does it matter if the sqlDataSource is with in the ContentTemplate of the CreateUserWizardSetp?
0
cer_petsafeAuthor Commented:
here is everything!

Public Partial Class NewUser
    Inherits System.Web.UI.Page
 
    Private Sub CreateUserWizard1_CreatedUser1(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizard1.CreatedUser
        Dim UserNameTextBox As TextBox = CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName")
        Dim DataSource As SqlDataSource = CreateUserWizardStep2.ContentTemplateContainer.FindControl("InsertExtraInfo")
        Dim User As MembershipUser = Membership.GetUser(UserNameTextBox.Text)
        Dim UserGUID As String = User.ProviderUserKey.ToString
        'DataSource.InsertParameters("UserId").DefaultValue = UserGUID.ToString
        DataSource.InsertParameters.Add("UserId", UserGUID)
        DataSource.Insert()
    End Sub
 
End Class
 
 
..................................
 
 
 
<body>
    <form id="form1" runat="server">
        <asp:Panel Id="outerPanel" runat="server" ScrollBars="none" BorderColor="#E0E0E0" BorderWidth="1" Width="600" Height="470">
            <asp:Panel runat="server" ID="innerPanel">
                <asp:Table runat="server" BackColor='Transparent' >
                    <asp:TableRow >
                        <asp:TableCell BorderColor='Transparent' BorderWidth='0' Width='10'>
                        </asp:TableCell>
                        <asp:TableCell BorderColor='Transparent' BorderWidth='0' VerticalAlign='Top'>
                            <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" ContinueDestinationPageUrl="~/Home.aspx" RequireEmail="true"
                             StepNextButtonImageUrl="Images/Web/NEXT.JPG" StepNextButtonType="Image" StepNextButtonStyle-Height="20" 
                              FinishPreviousButtonImageUrl="Images/Web/PREVIOUS.JPG" FinishPreviousButtonType="Image" FinishPreviousButtonStyle-Width="20"
                             StepPreviousButtonImageUrl="Images/Web/PREVIOUS.JPG" StepPreviousButtonType="Image" StepPreviousButtonStyle-Height="20" 
                             CreateUserButtonImageUrl="Images/Web/CREATE.JPG" CreateUserButtonType="Image" CreateUserButtonStyle-Height="20"
                              ContinueButtonImageUrl="Images/Web/CONTINUE.JPG" ContinueButtonType="Image" ContinueButtonStyle-Height="20" 
                               StartNextButtonImageUrl="Images/Web/NEXT.JPG" StartNextButtonType="Image" StartNextButtonStyle-Height="20"  >
                                <TitleTextStyle Font-Size="small" Font-Bold="true" HorizontalAlign="Center" BorderWidth="10" ForeColor="#b12621" />
                                <TextBoxStyle  BorderColor="#808080" BackColor="#E0E0E0" BorderWidth="1"  BorderStyle="Solid"/>
                                <WizardSteps>
                                   <asp:WizardStep ID="CreateUserWizardStep1" runat="server">
                                        <table>
                                            <tr>
                                                <th><label class="o2">New Account Information</label></th>
                                            </tr>
                                             <tr>
                                                <td>First Name:</td>
                                                <td>
                                                    
                                                    <asp:TextBox runat="server" ID="FirstName" MaxLength="50" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="FirstName"
                                                         ErrorMessage="First Name is required." />
                                                </td>
                                            </tr> 
                                             <tr>
                                                <td>Last Name:</td>
                                                <td>
                                                    
                                                    <asp:TextBox runat="server" ID="LastName" MaxLength="50" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0"  /><label class="o2">*</label>
                                                    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator2" ControlToValidate="LastName"
                                                         ErrorMessage="Last Name is required." />
                                                </td>
                                            </tr> 
                                            <tr>
                                                <td>Address:</td>
                                                <td>
                                                
                                                    <asp:TextBox runat="server" ID="ShippingAddress" MaxLength="50" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" />
                                                </td>
                                            </tr> 
                                            <tr>
                                                <td>City:</td>
                                                <td>
                                                    <asp:TextBox runat="server" ID="ShippingCity" MaxLength="50" Columns="15" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" />
                                                </td>
                                            </tr>  
                                            <tr>
                                                <td>State:</td>
                                                <td>
                                                    <asp:TextBox runat="server" ID="ShippingState" MaxLength="25" Columns="10" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" />
                                                </td>
                                            </tr>   
                                            <tr>
                                                <td>Zip:</td>
                                                <td>
                                                    
                                                    <asp:TextBox runat="server" ID="ShippingZip" MaxLength="10" Columns="10" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator8" ControlToValidate="ShippingZip"
                                                         ErrorMessage="Zip Code is required." />
                                                </td>
                                            </tr>
                                             <tr>
                                                <td>Phone Number:</td>
                                                <td>
                                                    <asp:TextBox runat="server" ID="Phone" MaxLength="50" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" />
                                                </td>
                                            </tr> 
                                        </table>
                                        <p>Sign up now to recieve access to detailed 
                                        iHouse decking configurations and the ability to
                                        quote and purchase kits and products. Registration
                                        is free and there are no obligations.</p>
                                        <p></p><p></p>
                                        <label class="o3">* Fields are required.</label>
                                    </asp:WizardStep>
                                    <asp:CreateUserWizardStep ID="CreateUserWizardStep2" runat="server">
                                        <ContentTemplate>
                                            <table>
                                                <tr>
                                                    <th>User Information</th>
                                                </tr>
                                                <tr>
                                                    <td>Username:</td>
                                                    <td>
                                                        
                                                        <asp:TextBox runat="server" ID="UserName" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator9" ControlToValidate="UserName" 
                                                            ErrorMessage="Username is required." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Password:</td>
                                                    <td>
                                                        
                                                        <asp:TextBox runat="server" ID="Password" TextMode="Password" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator10" ControlToValidate="Password" 
                                                            ErrorMessage="Password is required." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Confirm Password:</td>
                                                    <td>
                                                        
                                                        <asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator13" ControlToValidate="ConfirmPassword" 
                                                            ErrorMessage="Confirm Password is required." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Email:</td>
                                                    <td>
                                                        
                                                        <asp:TextBox runat="server" ID="Email" BorderColor="#808080" BorderWidth="1" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator11" ControlToValidate="Email" 
                                                            ErrorMessage="Email is required." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Question:</td>
                                                    <td>
                                                        
                                                        <asp:TextBox runat="server" ID="Question" BorderColor="#808080" BorderWidth="1" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator12" ControlToValidate="Question" 
                                                            ErrorMessage="Question is required." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Answer:</td>
                                                    <td>
                                                        
                                                        <asp:TextBox runat="server" ID="Answer" BorderColor="#808080" BorderWidth="1" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator14" ControlToValidate="Answer" 
                                                            ErrorMessage="Answer is required." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2">
                                                         <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password"
                                                                ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."></asp:CompareValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2">
                                                        <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                                                    </td>
                                                </tr>
                                            </table>
                                            <p></p>
                                            <label class="o3">* Fields are required.</label>
                                            <asp:SqlDataSource ID="InsertExtraInfo" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>" 
                                                InsertCommand="INSERT INTO [UserAddresses] ([UserId], [FirstName], [LastName], [Phone], [ShippingAddress], [ShippingCity], [ShippingState], [ShippingZip]) 
                                                               VALUES (@UserId, @FirstName, @LastName, @Phone, @ShippingAddress, @ShippingCity, @ShippingState, @ShippingZip)"
                                                ProviderName="<%$ ConnectionStrings:ConnectionString2.ProviderName %>">
                                                <InsertParameters>
                                                    <asp:ControlParameter Name="FirstName" Type="String" ControlID="FirstName" PropertyName="Text" />
                                                    <asp:ControlParameter Name="LastName" Type="String" ControlID="LastName" PropertyName="Text" />
                                                    <asp:ControlParameter Name="Phone" Type="String" ControlID="Phone" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingAddress" Type="String" ControlID="ShippingAddress" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingCity" Type="String" ControlID="ShippingCity" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingState" Type="String" ControlID="ShippingState" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingZip" Type="String" ControlID="ShippingZip" PropertyName="Text" />
                                                </InsertParameters>
                                            </asp:SqlDataSource>
                                        </ContentTemplate>
                                    </asp:CreateUserWizardStep>
                                    <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server" AllowReturn="true" />
                                </WizardSteps>
                            </asp:CreateUserWizard>
                           
                            
                        </asp:TableCell>
                    </asp:TableRow>
                </asp:Table>
            </asp:Panel> 
        </asp:Panel>
    </form>
</body>

Open in new window

0
jinalCommented:

Public Partial Class NewUser
    Inherits System.Web.UI.Page
 
    Private Sub CreateUserWizard1_CreatedUser1(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizard1.CreatedUser
        Dim UserNameTextBox As TextBox = CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName")
        Dim DataSource As SqlDataSource = CreateUserWizardStep2.ContentTemplateContainer.FindControl("InsertExtraInfo")
        Dim User As MembershipUser = Membership.GetUser(UserNameTextBox.Text)
        DataSource.InsertParameters.Add("UserId", User.ProviderUserKey)
        DataSource.Insert()
    End Sub
 
End Class
 
 
..................................
 
 
 
<body>
    <form id="form1" runat="server">
        <asp:Panel Id="outerPanel" runat="server" ScrollBars="none" BorderColor="#E0E0E0" BorderWidth="1" Width="600" Height="470">
            <asp:Panel runat="server" ID="innerPanel">
                <asp:Table runat="server" BackColor='Transparent' >
                    <asp:TableRow >
                        <asp:TableCell BorderColor='Transparent' BorderWidth='0' Width='10'>
                        </asp:TableCell>
                        <asp:TableCell BorderColor='Transparent' BorderWidth='0' VerticalAlign='Top'>
                            <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" ContinueDestinationPageUrl="~/Home.aspx" RequireEmail="true"
                             StepNextButtonImageUrl="Images/Web/NEXT.JPG" StepNextButtonType="Image" StepNextButtonStyle-Height="20" 
                              FinishPreviousButtonImageUrl="Images/Web/PREVIOUS.JPG" FinishPreviousButtonType="Image" FinishPreviousButtonStyle-Width="20"
                             StepPreviousButtonImageUrl="Images/Web/PREVIOUS.JPG" StepPreviousButtonType="Image" StepPreviousButtonStyle-Height="20" 
                             CreateUserButtonImageUrl="Images/Web/CREATE.JPG" CreateUserButtonType="Image" CreateUserButtonStyle-Height="20"
                              ContinueButtonImageUrl="Images/Web/CONTINUE.JPG" ContinueButtonType="Image" ContinueButtonStyle-Height="20" 
                               StartNextButtonImageUrl="Images/Web/NEXT.JPG" StartNextButtonType="Image" StartNextButtonStyle-Height="20"  >
                                <TitleTextStyle Font-Size="small" Font-Bold="true" HorizontalAlign="Center" BorderWidth="10" ForeColor="#b12621" />
                                <TextBoxStyle  BorderColor="#808080" BackColor="#E0E0E0" BorderWidth="1"  BorderStyle="Solid"/>
                                <WizardSteps>
                                   <asp:WizardStep ID="CreateUserWizardStep1" runat="server">
                                        <table>
                                            <tr>
                                                <th><label class="o2">New Account Information</label></th>
                                            </tr>
                                             <tr>
                                                <td>First Name:</td>
                                                <td>
                                                    
                                                    <asp:TextBox runat="server" ID="FirstName" MaxLength="50" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="FirstName"
                                                         ErrorMessage="First Name is required." />
                                                </td>
                                            </tr> 
                                             <tr>
                                                <td>Last Name:</td>
                                                <td>
                                                    
                                                    <asp:TextBox runat="server" ID="LastName" MaxLength="50" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0"  /><label class="o2">*</label>
                                                    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator2" ControlToValidate="LastName"
                                                         ErrorMessage="Last Name is required." />
                                                </td>
                                            </tr> 
                                            <tr>
                                                <td>Address:</td>
                                                <td>
                                                
                                                    <asp:TextBox runat="server" ID="ShippingAddress" MaxLength="50" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" />
                                                </td>
                                            </tr> 
                                            <tr>
                                                <td>City:</td>
                                                <td>
                                                    <asp:TextBox runat="server" ID="ShippingCity" MaxLength="50" Columns="15" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" />
                                                </td>
                                            </tr>  
                                            <tr>
                                                <td>State:</td>
                                                <td>
                                                    <asp:TextBox runat="server" ID="ShippingState" MaxLength="25" Columns="10" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" />
                                                </td>
                                            </tr>   
                                            <tr>
                                                <td>Zip:</td>
                                                <td>
                                                    
                                                    <asp:TextBox runat="server" ID="ShippingZip" MaxLength="10" Columns="10" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator8" ControlToValidate="ShippingZip"
                                                         ErrorMessage="Zip Code is required." />
                                                </td>
                                            </tr>
                                             <tr>
                                                <td>Phone Number:</td>
                                                <td>
                                                    <asp:TextBox runat="server" ID="Phone" MaxLength="50" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" />
                                                </td>
                                            </tr> 
                                        </table>
                                        <p>Sign up now to recieve access to detailed 
                                        iHouse decking configurations and the ability to
                                        quote and purchase kits and products. Registration
                                        is free and there are no obligations.</p>
                                        <p></p><p></p>
                                        <label class="o3">* Fields are required.</label>
                                    </asp:WizardStep>
                                    <asp:CreateUserWizardStep ID="CreateUserWizardStep2" runat="server">
                                        <ContentTemplate>
                                            <table>
                                                <tr>
                                                    <th>User Information</th>
                                                </tr>
                                                <tr>
                                                    <td>Username:</td>
                                                    <td>
                                                        
                                                        <asp:TextBox runat="server" ID="UserName" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator9" ControlToValidate="UserName" 
                                                            ErrorMessage="Username is required." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Password:</td>
                                                    <td>
                                                        
                                                        <asp:TextBox runat="server" ID="Password" TextMode="Password" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator10" ControlToValidate="Password" 
                                                            ErrorMessage="Password is required." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Confirm Password:</td>
                                                    <td>
                                                        
                                                        <asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator13" ControlToValidate="ConfirmPassword" 
                                                            ErrorMessage="Confirm Password is required." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Email:</td>
                                                    <td>
                                                        
                                                        <asp:TextBox runat="server" ID="Email" BorderColor="#808080" BorderWidth="1" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator11" ControlToValidate="Email" 
                                                            ErrorMessage="Email is required." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Question:</td>
                                                    <td>
                                                        
                                                        <asp:TextBox runat="server" ID="Question" BorderColor="#808080" BorderWidth="1" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator12" ControlToValidate="Question" 
                                                            ErrorMessage="Question is required." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Answer:</td>
                                                    <td>
                                                        
                                                        <asp:TextBox runat="server" ID="Answer" BorderColor="#808080" BorderWidth="1" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator14" ControlToValidate="Answer" 
                                                            ErrorMessage="Answer is required." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2">
                                                         <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password"
                                                                ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."></asp:CompareValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2">
                                                        <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                                                    </td>
                                                </tr>
                                            </table>
                                            <p></p>
                                            <label class="o3">* Fields are required.</label>
                                            <asp:SqlDataSource ID="InsertExtraInfo" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>" 
                                                InsertCommand="INSERT INTO [UserAddresses] ([UserId], [FirstName], [LastName], [Phone], [ShippingAddress], [ShippingCity], [ShippingState], [ShippingZip]) 
                                                               VALUES (@UserId, @FirstName, @LastName, @Phone, @ShippingAddress, @ShippingCity, @ShippingState, @ShippingZip)"
                                                ProviderName="<%$ ConnectionStrings:ConnectionString2.ProviderName %>">
                                                <InsertParameters>
                                                    <asp:ControlParameter Name="FirstName" Type="String" ControlID="FirstName" PropertyName="Text" />
                                                    <asp:ControlParameter Name="LastName" Type="String" ControlID="LastName" PropertyName="Text" />
                                                    <asp:ControlParameter Name="Phone" Type="String" ControlID="Phone" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingAddress" Type="String" ControlID="ShippingAddress" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingCity" Type="String" ControlID="ShippingCity" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingState" Type="String" ControlID="ShippingState" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingZip" Type="String" ControlID="ShippingZip" PropertyName="Text" />
                                                </InsertParameters>
                                            </asp:SqlDataSource>
                                        </ContentTemplate>
                                    </asp:CreateUserWizardStep>
                                    <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server" AllowReturn="true" />
                                </WizardSteps>
                            </asp:CreateUserWizard>
                           
                            
                        </asp:TableCell>
                    </asp:TableRow>
                </asp:Table>
            </asp:Panel> 
        </asp:Panel>
    </form>
</body>

Open in new window

0
jinalCommented:

Public Partial Class NewUser
    Inherits System.Web.UI.Page
 
    Private Sub CreateUserWizard1_CreatedUser1(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizard1.CreatedUser
        Dim UserNameTextBox As TextBox = CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName")
        Dim DataSource As SqlDataSource = CreateUserWizardStep2.ContentTemplateContainer.FindControl("InsertExtraInfo")
        Dim User As MembershipUser = Membership.GetUser(UserNameTextBox.Text)
        Dim guiduserid As Guid = CType(User.ProviderUserKey, Guid)
        DataSource.InsertParameters.Add("UserId", guiduserid)
        DataSource.Insert()
    End Sub
 
End Class
 
 
..................................
 
 
 
<body>
    <form id="form1" runat="server">
        <asp:Panel Id="outerPanel" runat="server" ScrollBars="none" BorderColor="#E0E0E0" BorderWidth="1" Width="600" Height="470">
            <asp:Panel runat="server" ID="innerPanel">
                <asp:Table runat="server" BackColor='Transparent' >
                    <asp:TableRow >
                        <asp:TableCell BorderColor='Transparent' BorderWidth='0' Width='10'>
                        </asp:TableCell>
                        <asp:TableCell BorderColor='Transparent' BorderWidth='0' VerticalAlign='Top'>
                            <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" ContinueDestinationPageUrl="~/Home.aspx" RequireEmail="true"
                             StepNextButtonImageUrl="Images/Web/NEXT.JPG" StepNextButtonType="Image" StepNextButtonStyle-Height="20" 
                              FinishPreviousButtonImageUrl="Images/Web/PREVIOUS.JPG" FinishPreviousButtonType="Image" FinishPreviousButtonStyle-Width="20"
                             StepPreviousButtonImageUrl="Images/Web/PREVIOUS.JPG" StepPreviousButtonType="Image" StepPreviousButtonStyle-Height="20" 
                             CreateUserButtonImageUrl="Images/Web/CREATE.JPG" CreateUserButtonType="Image" CreateUserButtonStyle-Height="20"
                              ContinueButtonImageUrl="Images/Web/CONTINUE.JPG" ContinueButtonType="Image" ContinueButtonStyle-Height="20" 
                               StartNextButtonImageUrl="Images/Web/NEXT.JPG" StartNextButtonType="Image" StartNextButtonStyle-Height="20"  >
                                <TitleTextStyle Font-Size="small" Font-Bold="true" HorizontalAlign="Center" BorderWidth="10" ForeColor="#b12621" />
                                <TextBoxStyle  BorderColor="#808080" BackColor="#E0E0E0" BorderWidth="1"  BorderStyle="Solid"/>
                                <WizardSteps>
                                   <asp:WizardStep ID="CreateUserWizardStep1" runat="server">
                                        <table>
                                            <tr>
                                                <th><label class="o2">New Account Information</label></th>
                                            </tr>
                                             <tr>
                                                <td>First Name:</td>
                                                <td>
                                                    
                                                    <asp:TextBox runat="server" ID="FirstName" MaxLength="50" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="FirstName"
                                                         ErrorMessage="First Name is required." />
                                                </td>
                                            </tr> 
                                             <tr>
                                                <td>Last Name:</td>
                                                <td>
                                                    
                                                    <asp:TextBox runat="server" ID="LastName" MaxLength="50" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0"  /><label class="o2">*</label>
                                                    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator2" ControlToValidate="LastName"
                                                         ErrorMessage="Last Name is required." />
                                                </td>
                                            </tr> 
                                            <tr>
                                                <td>Address:</td>
                                                <td>
                                                
                                                    <asp:TextBox runat="server" ID="ShippingAddress" MaxLength="50" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" />
                                                </td>
                                            </tr> 
                                            <tr>
                                                <td>City:</td>
                                                <td>
                                                    <asp:TextBox runat="server" ID="ShippingCity" MaxLength="50" Columns="15" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" />
                                                </td>
                                            </tr>  
                                            <tr>
                                                <td>State:</td>
                                                <td>
                                                    <asp:TextBox runat="server" ID="ShippingState" MaxLength="25" Columns="10" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" />
                                                </td>
                                            </tr>   
                                            <tr>
                                                <td>Zip:</td>
                                                <td>
                                                    
                                                    <asp:TextBox runat="server" ID="ShippingZip" MaxLength="10" Columns="10" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator8" ControlToValidate="ShippingZip"
                                                         ErrorMessage="Zip Code is required." />
                                                </td>
                                            </tr>
                                             <tr>
                                                <td>Phone Number:</td>
                                                <td>
                                                    <asp:TextBox runat="server" ID="Phone" MaxLength="50" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" />
                                                </td>
                                            </tr> 
                                        </table>
                                        <p>Sign up now to recieve access to detailed 
                                        iHouse decking configurations and the ability to
                                        quote and purchase kits and products. Registration
                                        is free and there are no obligations.</p>
                                        <p></p><p></p>
                                        <label class="o3">* Fields are required.</label>
                                    </asp:WizardStep>
                                    <asp:CreateUserWizardStep ID="CreateUserWizardStep2" runat="server">
                                        <ContentTemplate>
                                            <table>
                                                <tr>
                                                    <th>User Information</th>
                                                </tr>
                                                <tr>
                                                    <td>Username:</td>
                                                    <td>
                                                        
                                                        <asp:TextBox runat="server" ID="UserName" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator9" ControlToValidate="UserName" 
                                                            ErrorMessage="Username is required." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Password:</td>
                                                    <td>
                                                        
                                                        <asp:TextBox runat="server" ID="Password" TextMode="Password" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator10" ControlToValidate="Password" 
                                                            ErrorMessage="Password is required." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Confirm Password:</td>
                                                    <td>
                                                        
                                                        <asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" BorderWidth="1" BorderColor="#808080" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator13" ControlToValidate="ConfirmPassword" 
                                                            ErrorMessage="Confirm Password is required." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Email:</td>
                                                    <td>
                                                        
                                                        <asp:TextBox runat="server" ID="Email" BorderColor="#808080" BorderWidth="1" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator11" ControlToValidate="Email" 
                                                            ErrorMessage="Email is required." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Question:</td>
                                                    <td>
                                                        
                                                        <asp:TextBox runat="server" ID="Question" BorderColor="#808080" BorderWidth="1" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator12" ControlToValidate="Question" 
                                                            ErrorMessage="Question is required." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Answer:</td>
                                                    <td>
                                                        
                                                        <asp:TextBox runat="server" ID="Answer" BorderColor="#808080" BorderWidth="1" BackColor="#E0E0E0" /><label class="o2">*</label>
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator14" ControlToValidate="Answer" 
                                                            ErrorMessage="Answer is required." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2">
                                                         <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password"
                                                                ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."></asp:CompareValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2">
                                                        <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                                                    </td>
                                                </tr>
                                            </table>
                                            <p></p>
                                            <label class="o3">* Fields are required.</label>
                                            <asp:SqlDataSource ID="InsertExtraInfo" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>" 
                                                InsertCommand="INSERT INTO [UserAddresses] ([UserId], [FirstName], [LastName], [Phone], [ShippingAddress], [ShippingCity], [ShippingState], [ShippingZip]) 
                                                               VALUES (@UserId, @FirstName, @LastName, @Phone, @ShippingAddress, @ShippingCity, @ShippingState, @ShippingZip)"
                                                ProviderName="<%$ ConnectionStrings:ConnectionString2.ProviderName %>">
                                                <InsertParameters>
                                                    <asp:ControlParameter Name="FirstName" Type="String" ControlID="FirstName" PropertyName="Text" />
                                                    <asp:ControlParameter Name="LastName" Type="String" ControlID="LastName" PropertyName="Text" />
                                                    <asp:ControlParameter Name="Phone" Type="String" ControlID="Phone" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingAddress" Type="String" ControlID="ShippingAddress" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingCity" Type="String" ControlID="ShippingCity" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingState" Type="String" ControlID="ShippingState" PropertyName="Text" />
                                                    <asp:ControlParameter Name="ShippingZip" Type="String" ControlID="ShippingZip" PropertyName="Text" />
                                                </InsertParameters>
                                            </asp:SqlDataSource>
                                        </ContentTemplate>
                                    </asp:CreateUserWizardStep>
                                    <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server" AllowReturn="true" />
                                </WizardSteps>
                            </asp:CreateUserWizard>
                           
                            
                        </asp:TableCell>
                    </asp:TableRow>
                </asp:Table>
            </asp:Panel> 
        </asp:Panel>
    </form>
</body>

Open in new window

0
cer_petsafeAuthor Commented:
"Conversion from type 'Guid' to type 'String' is not valid."
0
jinalCommented:
try my last comment.
0
guru_samiCommented:
InsertParameters take String as value:
 DataSource.InsertParameters.Add("UserId", guiduserid.ToString)
0
cer_petsafeAuthor Commented:
Nope!  In all cases I can see the string value of the guid when I step through the code.  It errors on DataSource.Insert() which tells me its a sql thing.
0
guru_samiCommented:
I had one more look and with these settings it should work:
Having SqlDataSource inside the CUW is not a problem.
Just few more questions for you:
1: Are you getting the same error with the code given below?
2: Are your sure its not other parameters causing problem?
3: Can you use Sql Profiler and see whats going on....

Note: I did not make any chages to code below ... but this is the code you provided last time and I couldn't see anything wrong in there.

<asp:SqlDataSource ID="InsertExtraInfo" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>"
 InsertCommand="INSERT INTO [UserAddresses] ([UserId], [FirstName], [LastName], [Phone], [ShippingAddress], [ShippingCity], [ShippingState], [ShippingZip])
 VALUES (@UserId, @FirstName, @LastName, @Phone, @ShippingAddress, @ShippingCity, @ShippingState, @ShippingZip)"
ProviderName="<%$ ConnectionStrings:ConnectionString2.ProviderName %>">
<InsertParameters>
<asp:ControlParameter Name="FirstName" Type="String" ControlID="FirstName" PropertyName="Text" />
<asp:ControlParameter Name="LastName" Type="String" ControlID="LastName" PropertyName="Text" />
<asp:ControlParameter Name="Phone" Type="String" ControlID="Phone" PropertyName="Text" />
<asp:ControlParameter Name="ShippingAddress" Type="String" ControlID="ShippingAddress" PropertyName="Text" />
<asp:ControlParameter Name="ShippingCity" Type="String" ControlID="ShippingCity" PropertyName="Text" />
<asp:ControlParameter Name="ShippingState" Type="String" ControlID="ShippingState" PropertyName="Text" />
<asp:ControlParameter Name="ShippingZip" Type="String" ControlID="ShippingZip" PropertyName="Text" />
</InsertParameters>
</asp:SqlDataSource>

-------------
Private Sub CreateUserWizard1_CreatedUser1(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizard1.CreatedUser
Dim UserNameTextBox As TextBox = CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName")
Dim DataSource As SqlDataSource = CreateUserWizardStep2.ContentTemplateContainer.FindControl("InsertExtraInfo")
Dim User As MembershipUser = Membership.GetUser(UserNameTextBox.Text)
Dim UserGUID As String = User.ProviderUserKey.ToString
DataSource.InsertParameters.Add("UserId", UserGUID)
DataSource.Insert()
End Sub

0
cer_petsafeAuthor Commented:
guru_sami

1. yes this code gives me the same error.
2. there are no other parameters being inserted in this manner, You have the entire code.
3. I'll have to look into using Sql Profiler, I never used it before.
0
guru_samiCommented:
sorry...we have so many errors one after another....can you tell the last error message you are observing...because I do not see any reason for UserId to parameter to throw any error as the code looks fine.
May be also can you confirm you have UserId= uniqueidentifier in your DB as well.
0
cer_petsafeAuthor Commented:
The latest error is also the first:
"Implicit conversion from data type nvarchar to varbinary is not allowed. Use the CONVERT function to run this query."
...and yes the UserId type is uniqueidentifier.  

Unfortunately, I'm no longer at work today, so I'll have to tackle this again tomorrow.
0
guru_samiCommented:
May be check your other Fields in you DB...e.g. fn,ln address,phone, zip etc...
if anything is VARBINARY...thats what you need to change to VARCHAR...as all the paramters in your SqlDataSource are String type....or if you need anything to be VARBINARY in DB then you have to make proper change in the Code.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jinalCommented:

/* SQL Script */
CREATE TABLE [TestTable](
	[ID] [uniqueidentifier] NOT NULL,
	[Name] [varchar](50)  NOT NULL
)
 
/* Default2.aspx */
 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True" InsertCommand="Insert into testtable values(@ID,@Name)">
            <InsertParameters>
                <asp:Parameter DbType="Guid" Name="ID" />
                <asp:ControlParameter DbType="String" Name="Name" ControlID="TextBox1" PropertyName="Text" />
            </InsertParameters>
        </asp:SqlDataSource>
        <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
    </div>
    </form>
</body>
</html>
 
/* Default2.aspx.cs */
 
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Guid id = Guid.NewGuid();
        SqlDataSource1.InsertParameters["ID"].DefaultValue = id.ToString();        
        SqlDataSource1.Insert();
    }
}

Open in new window

0
cer_petsafeAuthor Commented:
OK I solved the problem by creating a new table.  It is exactly the same as the previous, so I'm not sure why  the new one works and the old one does not.  I'm awarding points to both 'jinal' and 'guru_sami' because I believe both had equally contributed and both had solutions that SHOULD have worked.  
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.