> Dim thisStringBuilder As System.Text.StringBuilder
> thisStringBuilder = New System.Text.StringBuilder
> Dim thisWord As VocabularyWord
> For Each thisWord In GameData.AllWords
> thisStringBuilder.Append(thisWord.EnglishWord)
> thisStringBuilder.Append(" = ")
> thisStringBuilder.Append( _
> thisWord.GermanWordWithArticleIfExists)
> thisStringBuilder.Append(vbCrLf) 'Новая строка
> Next
> 'Отобразить список слов в текстовом окне
> TextBox1.Text = thisStringBuilder.ToString()
>End Sub
Листинг 14.6. Пример кода управления данными для DatabaseAccess.cs
>Option Strict On
>'----------------------------------------------------------
>'Код доступа к базе данных: Этот класс управляет доступом в
>'базу данных наших приложений
>'----------------------------------------------------------
>Imports System
>Friend Class DatabaseAccess
>Const DATABASE_NAME As String = "LearnGerman.sdf"
>Const CONNECT_STRING As String = _
> "Data Source = " + DATABASE_NAME + "; Password = ''"
>Const TRANSLATIONTABLE_NAME As String = "TranslationDictionary"
>Const TRANSLATIONTABLE_ENGLISH_COLUMN As String = "EnglishWord"
>Const TRANSLATIONTABLE_GERMAN_COLUMN As String = "GermanWord"
>Const TRANSLATIONTABLE_GERMANGENDER_COLUMN As String = "GermanGender"
>Const TRANSLATIONTABLE_WORDFUNCTION_COLUMN As String = "WordFunction"
>Friend Const DS_WORDS_COLUMNINDEX_ENGLISHWORD As Integer = 0
>Friend Const DS_WORDS_COLUMNINDEX_GERMANWORD As Integer = 1
>Friend Const DS_WORDS_COLUMNINDEX_GERMANGENDER As Integer = 2
>Friend Const DS_WORDS_COLUMNINDEX_WORDFUNCTION As Integer = 3
>Public Shared Function GetListOfWords() As _
> System.Data.IDataReader
> Dim conn As System.Data.SqlServerCe.SqlCeConnection = Nothing
> conn = New System.Data.Sq]ServerCe.SqlCeConnection( _
> CONNECT_STRING)
> conn.Open()
> Dim cmd As System.Data.SqlServerCe.SqlCeCommand = _
> conn.CreateCommand()
> cmd.CommandText = "select " + _
> TRANSLATIONTABLE_ENGLISH_COLUMN + ", " _
> + TRANSLATIONTABLE_GERMAN_COLUMN + ", " _
> + TRANSLATIONTABLE_GERMANGENDER_COLUMN + ", " _
> + TRANSLATIONTABLE_WORDFUNCTION_COLUMN + " " _
> + "from " + TRANSLATIONTABLE_NAME
> 'Выполнить команду базы данных
> Dim myReader As System.Data.SqlServerCe.SqlCeDataReader = _
> cmd.ExecuteReader(System.Data.CommandBehavior.SingleResult)
> Return myReader
>End Function
>'------------------------------------------
>'Создает базу данных в случае необходимости
>'------------------------------------------
>Public Shared Sub CreateDatabaseIfNonExistant()
> If (System.IO.File.Exists(DATABASE_NAME) = False) Then
> CreateAndFillDatabase()
> End If
>End Sub
>'---------------------------------------