Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

sqlDataSource.InsertParameter type conversion problem

Posted on 2009-07-16
25
1,212 Views
Last Modified: 2012-06-21
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

0
Comment
Question by:cer_petsafe
  • 10
  • 8
  • 7
25 Comments
 
LVL 41

Expert Comment

by:guru_sami
ID: 24871468
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
 
LVL 41

Expert Comment

by:guru_sami
ID: 24871533
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
 
LVL 15

Expert Comment

by:jinal
ID: 24871673
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 15

Expert Comment

by:jinal
ID: 24871680

 <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
 

Author Comment

by:cer_petsafe
ID: 24871786
the type in the DB is uniqueidentifier.  I've tried  DbType="Guid" or Type="Object", still no luck!
0
 
LVL 15

Expert Comment

by:jinal
ID: 24871812
<asp:Parameter Name="UserId" DbType="Guid" Type="String"/>

0
 

Author Comment

by:cer_petsafe
ID: 24871841
Error: "The Type property of parameter 'UserId' cannot be set when the DbType property is set."
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24871937
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
 

Author Comment

by:cer_petsafe
ID: 24872041
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
 
LVL 41

Expert Comment

by:guru_sami
ID: 24872055
alrite how about posting your current complete code here once again.
0
 

Author Comment

by:cer_petsafe
ID: 24872103
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
 

Author Comment

by:cer_petsafe
ID: 24872112
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
 
LVL 15

Expert Comment

by:jinal
ID: 24872166

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
 
LVL 15

Expert Comment

by:jinal
ID: 24872200

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
 

Author Comment

by:cer_petsafe
ID: 24872205
"Conversion from type 'Guid' to type 'String' is not valid."
0
 
LVL 15

Expert Comment

by:jinal
ID: 24872233
try my last comment.
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24872234
InsertParameters take String as value:
 DataSource.InsertParameters.Add("UserId", guiduserid.ToString)
0
 

Author Comment

by:cer_petsafe
ID: 24872274
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
 
LVL 41

Expert Comment

by:guru_sami
ID: 24873424
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
 

Author Comment

by:cer_petsafe
ID: 24873536
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
 
LVL 41

Expert Comment

by:guru_sami
ID: 24873613
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
 

Author Comment

by:cer_petsafe
ID: 24874004
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
 
LVL 41

Accepted Solution

by:
guru_sami earned 250 total points
ID: 24874106
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
 
LVL 15

Assisted Solution

by:jinal
jinal earned 250 total points
ID: 24875855

/* 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
 

Author Comment

by:cer_petsafe
ID: 24878097
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

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

838 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