?
Solved

ASP.NET - easiest way to insert records

Posted on 2012-03-21
1
Medium Priority
?
230 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
[X]
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
1 Comment
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 1500 total points
ID: 37746110
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

764 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