I have this code in my aspx file:

<asp:SqlDataSource ID="RegisterUserSQL" runat="server" ConnectionString="<%$ ConnectionStrings:UserQueries %>" ProviderName="<%$ ConnectionStrings:UserQueries.ProviderName %>"
        InsertCommand="insert into users (firstname, lastname, username, password, email, gender, birthdate, nationality, currentcity) 
        values (:firstname, :lastname, :username, :password, :email, :gender, :date, :nationality, :currentcity)">
        <InsertParameters>
            <asp:Parameter Name="firstname" Type="String" />
            <asp:Parameter Name="lastname" Type="String" />
            <asp:Parameter Name="username" Type="String" />
            <asp:Parameter Name="password" Type="String" />
            <asp:Parameter Name="email" Type="String" />
            <asp:Parameter Name="gender" Type="Char" />
            <asp:Parameter Name="date" Type="String" />
            <asp:Parameter Name="nationality" Type="String" />
            <asp:Parameter Name="currentcity" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>

Then this is the code behind:

 RegisterUserSQL.InsertParameters["firstname"].DefaultValue = SavedFirstnameBox.Text;
                        RegisterUserSQL.InsertParameters["lastname"].DefaultValue = SavedLastnameBox.Text;
                        RegisterUserSQL.InsertParameters["username"].DefaultValue = SavedUsernameBox.Text;
                        RegisterUserSQL.InsertParameters["password"].DefaultValue = SavedPasswordBox.Text;
                        RegisterUserSQL.InsertParameters["email"].DefaultValue = SavedEmailBox.Text;
                        RegisterUserSQL.InsertParameters["gender"].DefaultValue = SavedGenderBox.Text;
                        RegisterUserSQL.InsertParameters["date"].DefaultValue = BirthdateBox.Text;
                        RegisterUserSQL.InsertParameters["nationality"].DefaultValue = SavedNationalityBox.Text;
                        RegisterUserSQL.InsertParameters["currentcity"].DefaultValue = SavedCurrentCityBox.Text;
                        RegisterUserSQL.Insert();

It stops at the last insert() statement and gives the error.

Any suggestions?

Related posts

Recent Viewed