locked
convert normal application to 3 tier RRS feed

  • Question

  • User383567333 posted

    plz anyone tell me how can i convert it into 3 tier ....

    i want to define connection in a class then pass the query using another class and return value from this cmd parameter ..

    plz reply me with example,especially "cmd.Parameters.AddWithValue...."


    OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["ncon"].ConnectionString);


                    OleDbCommand cmd = new OleDbCommand("insert into registration(nname, nemail, ntelephone, naddress, ndate, uname, upassword, usertype, umonth,nregistration,regdate,paydetail,servicetype,serviceperiod,uip,lname,paytype,ntelephoneoptional,nallow,nvalue,expdate) values(@name,@email,@tele,@address,@date,@uname,@upass,@utype,@month,@nreg,@regdate,@paydetail,@servicetype,@serviceperiod,@uip,@lname,@paytype,@ntelephoneoptional,'Deactive',@nvalue,@expdate)", con);

                    cmd.Parameters.AddWithValue("name", TextBox1.Text);
                    cmd.Parameters.AddWithValue("email", TextBox2.Text);
                    cmd.Parameters.AddWithValue("tele", TextBox3.Text);
                    cmd.Parameters.AddWithValue("address", TextBox4.Text);
                    cmd.Parameters.AddWithValue("date", TextBox5.Text);
                    cmd.Parameters.AddWithValue("uname", TextBox6.Text);
                    cmd.Parameters.AddWithValue("upass", TextBox7.Text);
                    cmd.Parameters.AddWithValue("utype", RadioButtonList1.SelectedItem.ToString());
                    cmd.Parameters.AddWithValue("month", TextBox5.Text);

                    cmd.Parameters.AddWithValue("nregistration", Label1.Text);

                    Label2.Text = DateTime.Now.ToString("MM/dd/yyyy");
                    cmd.Parameters.AddWithValue("regdate", Label2.Text);
                    
                    cmd.Parameters.AddWithValue("paydetail", "");
                    cmd.Parameters.AddWithValue("servicetype", DropDownList1.SelectedItem.Text);
                    cmd.Parameters.AddWithValue("serviceperiod", DropDownList2.SelectedItem.Text);
                    cmd.Parameters.AddWithValue("uip", Session["ipad"].ToString());
                    cmd.Parameters.AddWithValue("lname", TextBox9.Text);
                    cmd.Parameters.AddWithValue("paytype", RadioButtonList2.SelectedItem.Text);
                    cmd.Parameters.AddWithValue("ntelephoneoptional", TextBox11.Text);
                    cmd.Parameters.AddWithValue("nvalue", DropDownList1.SelectedValue);

    cmd.ExecuteNonQuery();

    con.Close();


    Wednesday, September 29, 2010 5:52 PM

Answers

  • User-821857111 posted

    Have a look at the SqlHelper classes in the Enterprise Library. That should provide the answer for you.

    http://msdn.microsoft.com/en-us/library/ff632023.aspx?rssCatalog


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 29, 2010 6:03 PM