public List <SurveyQ> getSurveyID() { List <SurveyQ> List = new List <SurveyQ>(); DataSet ds = new DataSet(); DataTable tdData = new DataTable(); StringBuilder sqlStr = new StringBuilder(); sqlStr.AppendLine("select * from SurveyQns"); SqlConnection myConn = new SqlConnection(DBConnect); SqlDataAdapter da = new SqlDataAdapter(sqlStr.ToString(), myConn); da.Fill(ds, "TableTD"); int rec_cnt = ds.Tables["TableTD"].Rows.Count; if (rec_cnt > 0) { foreach (DataRow row in ds.Tables["TableTD"].Rows) { SurveyQ slist = new SurveyQ(); slist.SurveyQID = row["SurveyQID"].ToString(); List.Add(slist); } } else { List = null; } return(List); }
public SurveyQ getSurveyQuestions() { DataSet ds = new DataSet(); DataTable tdData = new DataTable(); StringBuilder sqlStr = new StringBuilder(); sqlStr.AppendLine("select * from SurveyQns"); sqlStr.AppendLine("Where SurveyQID = (select min(SurveyQID) from SurveyQns);"); SqlConnection myConn = new SqlConnection(DBConnect); SqlDataAdapter da = new SqlDataAdapter(sqlStr.ToString(), myConn); da.Fill(ds, "TableTD"); int rec_cnt = ds.Tables["TableTD"].Rows.Count; SurveyQ myTD = new SurveyQ(); if (rec_cnt > 0) { DataRow row = ds.Tables["TableTD"].Rows[0]; myTD.q1 = row["Q1"].ToString(); myTD.q2 = row["Q2"].ToString(); myTD.q3 = row["Q3"].ToString(); myTD.q4 = row["Q4"].ToString(); } else { myTD = null; } return(myTD); }