visu862's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Authors
Active Posts:
10 (0.01 per day)
Joined:
07-March 11
Profile Views:
429
Last Active:
User is offline Sep 22 2011 07:35 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   visu862 has not set their status

Posts I've Made

  1. In Topic: Save button

    Posted 30 Jul 2011

    i try my best to identify the problem and make some changes in my code. can anyone explain where and what is my wrong in my code but still have this error "A page can have only one server-side Form tag".




     
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data.SqlClient;
    using System.Data;
    
    
    
    
    public partial class _Default : System.Web.UI.Page 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    
        public string GetConnectionString()
        {
            return System.Configuration.ConfigurationManager.ConnectionStrings["ASPNETDBConnectionString"].ConnectionString;
        }
    
        private void ExecuteInsert(string customer_id, string name, string gender, string calculate, string address, string nationality, string email, string mobile, string license, string rentdate, string returndate, string total)
        {
    
    
            SqlConnection conn = new SqlConnection (GetConnectionString());
    
            string sql = "INSERT INTO rental (customer_id, name, gender, address, nationality, email, mobile, license, rentdate, returndate, calculate, total) VALUES " + " (customer_id, name, gender, address, nationality, email, mobile, license, rentdate, returndate, calculate, total)";
    
            try
            {
                conn.Open();
    
                SqlCommand cmd = new SqlCommand(sql, conn);
                SqlParameter[] param = new SqlParameter[12];
    
    
                param[0] = new SqlParameter("customer_id",SqlDbType.VarChar, 50);
                param[1] = new SqlParameter("name", SqlDbType.VarChar, 50);
                param[2] = new SqlParameter("gender", SqlDbType.VarChar, 50);
                param[3] = new SqlParameter("address", SqlDbType.VarChar, 50);
                param[4] = new SqlParameter("nationality", SqlDbType.VarChar, 50);
                param[5] = new SqlParameter("email", SqlDbType.VarChar, 50);
                param[6] = new SqlParameter("mobile", SqlDbType.VarChar, 50);
                param[7] = new SqlParameter("licence", SqlDbType.VarChar, 50);
                param[8] = new SqlParameter("rentdate", SqlDbType.VarChar, 50);
                param[9] = new SqlParameter("returndate", SqlDbType.VarChar, 50);
                param[10] = new SqlParameter("calculate", SqlDbType.VarChar, 50);
                param[11] = new SqlParameter("total", SqlDbType.VarChar, 50);
    
    
    
                param[0].Value = customer_id;
                param[1].Value = name;
                param[2].Value = gender;
                param[3].Value = address;
                param[4].Value = nationality;
                param[5].Value = email;
                param[6].Value = mobile;
                param[7].Value = license;
                param[8].Value = rentdate;
                param[9].Value = returndate;
                param[10].Value = calculate;
                param[11].Value = total;
    
                
    
                for (int i = 0; i < param.Length; i++)
                {
                    cmd.Parameters.Add(param[i]);
                }
                cmd.CommandType = CommandType.Text;
                cmd.ExecuteNonQuery();
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                string msg = "Insert error:";
                msg += ex.Message;
                throw new Exception(msg);
            }
            finally
            {
                conn.Close();
            }
        }
        protected void btnsave_Click(object sender, EventArgs e)
        {
            ExecuteInsert(txtcustomer_id.Text, txtname.Text, txtgender.Text, txtaddress.Text, txtnationality.Text, txtemail.Text, txtmobile.Text, txtlicence.Text, txtrentdate.Text, txtreturndate.Text, txtcalculate.Text, txttotal.Text);
    
            Response.Write("Record was succesfully added!");
            
        }
        protected void txtcalculate_TextChanged(object sender, EventArgs e)
        {
    
        }
    }
    
    
    
  2. In Topic: Save button

    Posted 27 Jul 2011

    hi. thank you for your post. but can you explain more deeply witch can make me understand. thank you

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

visu862 hasn't added any friends yet.

Comments

visu862 has no profile comments yet. Why not say hello?