public String GetFileType(int pid) { SqlConnection conn = new SqlConnection(connectionString); String str = "select content_type from documents where id =" + pid; String content_type = ""; SqlCommand cmd = new SqlCommand(str, conn); try { conn.Open(); SqlDataReader rd = cmd.ExecuteReader(); if (rd.Read()) { CourseLocations rec = new CourseLocations(); content_type = rd["content_type"].ToString(); } return(content_type); } catch (Exception Ex) { MessageBox.Show("Error Occured:" + Ex.Message); return(null); } }
public List <CourseLocations> CourseLocationsList() { SqlConnection conn = new SqlConnection(connectionString); String str = "select id,deptname+'" + "'+Location CourseLocations from course"; SqlCommand cmd = new SqlCommand(str, conn); List <CourseLocations> CourseLocationsList = new List <CourseLocations>(); try { conn.Open(); SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { CourseLocations rec = new CourseLocations(); rec.Id = ((Int32)rd["id"]); rec.CourseLocation = rd["CourseLocations"].ToString(); CourseLocationsList.Add(rec); } return(CourseLocationsList); } catch (Exception Ex) { MessageBox.Show("Error Occured:" + Ex.Message); return(null); } }