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?