hi,pls
go through this code (when i use stored proc it works fine but when i use cmd.commandtype=commandtyp.text not inserting the values)
public _insert(string pName,int pAge,string pCity)//Works fine
{
SqlConnection cnn = new SqlConnection(Conn);
SqlCommand cmd = new SqlCommand("Ins_P", cnn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@pName", pName);
cmd.Parameters.AddWithValue("@pAge", pAge);
cmd.Parameters.AddWithValue("@pCity", pCity);
SqlDataAdapter ada = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
ada.Fill(ds);
return ds;
}
public _insert(string pName,int pAge,string pCity)//doesn't Works
{
SqlConnection cnn = new SqlConnection(Conn);
SqlCommand cmd = new SqlCommand("Insert into P values(pName,pAge,pCity)", cnn);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@pName", pName);
cmd.Parameters.AddWithValue("@pAge", pAge);
cmd.Parameters.AddWithValue("@pCity", pCity);
SqlDataAdapter ada = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
ada.Fill(ds);
return ds;
}
what should i used in 3rd statement instead of cmd.commandtype=commandtype.text pls tell me and the diff between these above two 3rd statements..
Join Hands Change lives
Thanks & Regards
Straight Edge Society