MYsql data reader if is null field c#
If is null field need to be empty
Datum = rd.GetString("DATUM"),
this
I have error if is empty
koneksi.Open();
var rd = cmd.ExecuteReader();
users = new List();
while (rd.Read())
{
users.Add(new user
{
Datum = rd.GetString("DATUM"),
}
);
}
rd.Close();
Khoday AkileshPosted Nov 2, 2023, 9:53 AM
string? Datum = rd.GetString("DATUM") != "" ? rd.GetString("DATUM") : null;
Jignesh KumarPosted Nov 2, 2023, 9:45 AM
Hello,
What is datatype of "Datum" in user model ?
Goran BibicPosted Nov 2, 2023, 9:37 AM
Error
Khoday AkileshPosted Nov 2, 2023, 9:17 AM
Could you share the error, which you are getting.