0
6 개의 문자열이있는 데이터 집합이 있습니다. 어떻게 데이터 집합의 이러한 문자열을 문자열 배열에 채울 수 있습니다. 이드는 루프 스루 (Loop Through) 데이터 세트를 상상해보십시오.
퀴즈 수업에 질의 응답이 있습니다.데이터 집합의 배열 채우기 C#
은 데이터 집합을 채우기위한 코드입니다.
SqlConnection connect = new SqlConnection(connectionString);
SqlCommand command = new SqlCommand();
command.Connection = connect;
command.CommandType = CommandType.Text;
command.CommandText = "Select * from Questions";
SqlDataAdapter dataapt = new SqlDataAdapter(command);
DataSet questions = new DataSet();
try
{
connect.Open();
dataapt.Fill(questions, "Questions");
}
을 heres 내 퀴즈 클래스
public class Quiz
{
public string[] questions { get; set; }
public string[] answers { get; set; }
public Quiz()
{
questions = new string[] { "First", "Second", "Third", "Fourth","Fifth","sixth" };
answers = new string[] { "First", "Second", "Third", "Fourth", "Fifth", "sixth" };
}
IT는 데이터 집합 배열을 기입 할 수있다 ??
예, 그렇습니다. 해보자! –