Click here to Skip to main content
15,906,766 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i m creating a small project in asp.net using c# on 3-tier architecture. i want to send seven parameters from web form to database. stored proc name is spuserdetails and parameter name are name,age,add,phno,country,state,city. my DAL code is as follows:
namespace Datalgc
{       
    public class Class1
    {
        string connStr = ConfigurationManager.ConnectionStrings["spuserdetails"].ToString();
        public int Insert(string Name, DateTime DOB, string  Addr,int phno,string Country,string State,String City)
        {
            SqlConnection conn = new SqlConnection(spuserdetails);
            conn.Open();
            SqlCommand Cmd = new SqlCommand("InsertData", conn);
            Cmd.CommandType = CommandType.StoredProcedure;
            try
            {
                Cmd.Parameters.AddWithValue("@Name", Name);
                Cmd.Parameters.AddWithValue("@DOB", DOB);
                Cmd.Parameters.AddWithValue("@Addr", Addr);
                Cmd.Parameters.AddWithValue("@phno", phno);
                Cmd.Parameters.AddWithValue("@Country", Country);
                Cmd.Parameters.AddWithValue("@State", State);
                Cmd.Parameters.AddWithValue("@City", City);
                return Cmd.ExecuteNonQuery();
            }
            catch
            {
                throw;
            }
            finally
            {
                Cmd.Dispose();
                conn.Close();
                conn.Dispose();
            }
        }
    }
}

the statement
Cmd.CommandType = CommandType.StoredProcedure;
shows that the commandtype does not exist in current context.why?
Posted
Updated 17-Jun-13 23:50pm
v2

1 solution

Include
C#
Using System.Data
at top of your code file.This is the common cause of this error.Let me know if it doesnt work.
 
Share this answer
 
v2
Comments
Rambo_Raja 18-Jun-13 5:57am    
yes it works...great!..thanx dear
Thanks7872 18-Jun-13 5:58am    
you are always welcome.Call again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900