Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspdotnet_website_programming thread: Insert file to database


Message #1 by "Lampros Eleftherios" <lampros@c...> on Tue, 23 Apr 2002 21:50:56 +0300
This is a multi-part message in MIME format.

------=_NextPart_000_002D_01C1EB10.F269D230
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello to all of you.
I am creating a registration form with ASP.NET and C#. The "systems" 
works fine but i don't want to insert a "data" that already is written 
to the database.
I used this script:

-------------------------------------------------------------------------
-------

<script language=3D"C#" runat=3D"server">

    SqlConnection myConnection;

    protected void Page_Load(Object Src, EventArgs E)
    {
        myConnection =3D new 
SqlConnection("server=3Dlocalhost;database=3Ddok_db;Trusted_Connection=3D
yes");

       
    }

    public void Add_Click(Object sender, EventArgs E)
    {
       

        if (Page.IsValid)
        {

            String insertCmd =3D "insert into user_name 
(user_first_name, user_last_name) values (@FName, @LName)";

            SqlCommand myCommand =3D new SqlCommand(insertCmd, 
myConnection);

           
            myCommand.Parameters.Add(new SqlParameter("@FName", 
SqlDbType.NVarChar, 50));
            myCommand.Parameters["@FName"].Value =3D 
user_first_name.Value;

            myCommand.Parameters.Add(new SqlParameter("@LName", 
SqlDbType.NVarChar, 50));
            myCommand.Parameters["@LName"].Value =3D 
user_last_name.Value;
          
                    }

            }
   
</script>

-------------------------------------------------------------------------
-------

Well. The code above sends entries to user_first_name and user_last_name 
and stores them to the database dok_db.
I don't want to add entries with the same user last or first name. Does 
anybody of you know how to do it? Please help me.

Thank  you in advanced.



  Return to Index