Solved

ASP.NET - easiest way to insert records

Posted on 2012-03-21
1
224 Views
Last Modified: 2012-03-23
Hi all.

What is the easiest way to insert record to database from asp.net web form ?

My form looks like this:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:MultiView ID="MultiView12" runat="server">
                <asp:View ID="Registracija1" runat="server">
                    <div class="center_title_bar">
                        Otvaranje novog naloga
                    </div>
                    <div class='forma_edit'>
                        <asp:ValidationSummary ID="ValidationSummary1" runat="server" CssClass="forma_edit_error_summary" />
                        <div class='forma_edit_tekst'>
                            Molimo Vas da unesete Vaše podatke. Polja oznacena sa * (zvjezdicom) je obavezno
                            unjeti.
                        </div>
                        <div class='forma_edit_name'>
                            Ime i Prezime*
                        </div>
                        <div class='forma_edit_field'>
                            <asp:TextBox ID='IKuDonameTXT' ClientIDMode="Static" runat='server' Width='420px'></asp:TextBox>
                            <asp:RequiredFieldValidator ErrorMessage="Morate upisati Ime i prezime" ControlToValidate="IKuDonameTXT"
                                CssClass="forma_edit_error" runat="server" />
                        </div>
                        <div class='forma_edit_name'>
                            Korisnicko ime*
                        </div>
                        <div class='forma_edit_field'>
                            <asp:TextBox ID='IWebSiteUsernameTXT' runat='server' Width='420px' />
                            <asp:RequiredFieldValidator ErrorMessage="Morate upisati korisnicko ime" ControlToValidate="IWebSiteUsernameTXT"
                              CssClass="forma_edit_error"   runat="server" />
                        </div>
                        <div class='forma_edit_descr'>
                            Ime koje cete koristiti kada se budete prijavljivali na sajt
                        </div>
                        <div class='forma_edit_name'>
                            Lozinka*
                        </div>
                        <div class='forma_edit_field'>
                            <asp:TextBox ID='IWebSitePasswordTXT' runat='server' Width='420px' />
                            <asp:RequiredFieldValidator ErrorMessage="Morate upisati lozinku" ControlToValidate="IWebSitePasswordTXT"
                               CssClass="forma_edit_error"  runat="server" />
                        </div>
                        <div class='forma_edit_name'>
                            JMBG*
                        </div>
                        <div class='forma_edit_field'>
                            <asp:TextBox ID='IKuDoPIBTXT' runat='server' Width='420px' />
                            <asp:RequiredFieldValidator ErrorMessage="Morate upisati JMBG" ControlToValidate="IKuDoPIBTXT"
                                CssClass="forma_edit_error" runat="server" Display="Dynamic" />
                        </div>
                        <div class='forma_edit_descr'>
                            Vas jedinstveni maticni broj (sluzi za provjeru Vasih podataka)
                        </div>
                        <div class='forma_edit_name'>
                            Mobilni Telefon*
                        </div>
                        <div class='forma_edit_field'>
                            <asp:TextBox ID='IKuDoTelefonMobilniTXT' runat='server' Width='420px' />
                            <asp:RequiredFieldValidator ErrorMessage="Morate upisati Mobilni telefon" ControlToValidate="IKuDoTelefonMobilniTXT"
                                CssClass="forma_edit_error" runat="server" />
                        </div>
                        <div class='forma_edit_name'>
                            Fiksni Telefon*
                        </div>
                        <div class='forma_edit_field'>
                            <asp:TextBox ID='IKuDoTelefonFiksniTXT' runat='server' Width='420px' />
                            <asp:RequiredFieldValidator ErrorMessage="Morate upisati Fiksni telefon" ControlToValidate="IKuDoTelefonFiksniTXT"
                                CssClass="forma_edit_error" runat="server" />
                        </div>
                        <div class='forma_edit_name'>
                            Adresa*
                        </div>
                        <div class='forma_edit_field'>
                            <asp:TextBox ID='IKuDoAdresaTXT' runat='server' Width='420px' />
                            <asp:RequiredFieldValidator ErrorMessage="Morate upisati adresu" ControlToValidate="IKuDoAdresaTXT"
                                CssClass="forma_edit_error" runat="server" />
                        </div>
                        <div class='forma_edit_descr'>
                            Vasa adresa u formatu Ulica i broj, Grad
                        </div>
                        <div class='forma_edit_name'>
                            Email adresa
                        </div>
                        <div class='forma_edit_field'>
                            <asp:TextBox ID='IEmailTXT' runat='server' Width='420px' />
                        </div>
                        <div class="forma_edit_komanda_insert">
                            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" Text="Sacuvaj" />
                        </div>
                    </div>
                </asp:View>
                <asp:View ID="Zavrseno" runat="server">
                    Uspjesno ste se registrovali. Molimo Vas da se ulogujete na vrhu stranice.
                </asp:View>
            </asp:MultiView>
        </ContentTemplate>
    </asp:UpdatePanel>

Open in new window


As you see, all fields are required except the last one (IEmailTXT).

Validation is working as it should, but now I need to do the inserting part.

What is the best way to do it ? I am using access database.

This is my insert command:

"INSERT INTO KuDo (KuDoID,KuDoNaziv,WebSiteUsername,WebSitePassword,KuDoPIB,KuDoTelefonMobilni,KuDoTelefonFiksni,KuDoAdresa,KuDoEmail) VALUES (@KuDoID,@KuDoNaziv,@WebSiteUsername,@WebSitePassword,@KuDoPIB,@KuDoTelefonMobilni,@KuDoTelefonFiksni,@KuDoAdresa,@KuDoEmail)"
0
Comment
Question by:mccom
1 Comment
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 total points
ID: 37746110
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now