データベースからリストに単語を書き込もうとしています。さて、私は言った lst.Add(reader.GetString(0));データベースをリストに読み込む
このコードでは、最初の列の単語をリストに読み込みます。今私はいつも次のエラーを取得します。
型「System.Data.SqlTypes.SqlNullValueException」の未処理の例外は、私はエラーを取得するなぜ私はそれを取得しないのSystem.Data.dll
で発生しました。誰か助言?
using (SqlConnection connection = new SqlConnection(@"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = D:\VisualStudio\Projects\runSheet\frontPage_V1.1\Jarvis\Jarvis\Jarvis\jarvisBrain.mdf; Integrated Security = True"))
{
connection.Open();
using (SqlCommand command = new SqlCommand("SELECT Word FROM ImportedWordList", connection))
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
lst.Add(reader.GetString(0));
}
}
richTextBox1.Lines = lst.ToArray();
connection.Close();
}
良い時間だ.... – Eser
はい、私は知っている、私は、それを愚かな探して質問についてとても残念自分自身を学んでいます。 – TMJ