Solved

ASP.NET - easiest way to insert records

Posted on 2012-03-21
1
227 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 500 total points
ID: 37746110
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 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