Exemplo n.º 1
0
        public List <AdprojectDetails> FetchProjectDetails()
        {
            // AdprojectDetails ProjName = new AdprojectDetails();
            List <AdprojectDetails> listofproject = new List <AdprojectDetails>();

            string con = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            using (SqlConnection conn = new SqlConnection(con))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("select ProjectName from LTProject", conn);
                //   flag = Convert.ToBoolean(cmd.ExecuteScalar());
                SqlDataReader dr = cmd.ExecuteReader();



                if (dr.FieldCount != 0)
                {
                    while (dr.Read())
                    {
                        AdprojectDetails ProjName1 = new AdprojectDetails();
                        ProjName1.ProjectName = dr["ProjectName"].ToString();
                        listofproject.Add(ProjName1);
                    }
                }
                return(listofproject);
            }
        }
Exemplo n.º 2
0
        public int InsertProjectToDB(AdprojectDetails AdprojectDetails)
        {
            int row = 0;

            string con = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            using (SqlConnection conn = new SqlConnection(con))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("insert into LTProject values('" + AdprojectDetails.ProjectName + "')", conn);
                //   flag = Convert.ToBoolean(cmd.ExecuteScalar());
                row = cmd.ExecuteNonQuery();
                if (row > 0)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
        }