Solved

ASP.NET - easiest way to insert records

Posted on 2012-03-21
1
222 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

705 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

19 Experts available now in Live!

Get 1:1 Help Now