Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
2 answers
267 views

How can I preempt the attempted assignment of DBNull to an int?

The following code: foreach (DataRow fillRateDataRow in dtFillRateResults.Rows) { . . . var frbdbc = new FillRateByDistributorByCustomer { ShortName = fillRateDataRow["ShortName"]....
B. Clay Shannon-B. Crow Raven's user avatar
1 vote
1 answer
3k views

DataRow ArrayItem's DataType for NULL Values vb.net

I am undergoing a scenario where I have DataTable and there are multiple types of columns in it, I have to filter out the Data Type of Null Valued Column so i can assign some default value to it, ...
DareDevil's user avatar
  • 5,349
0 votes
1 answer
2k views

c# datarow comparing DBNull.Value for DateTime vs null for string

I have the following code that seems to work: DataRow row = <result of a query>; string strVarName = (row["VarName"]??"").ToString(); I can also use something like this - and it also works: ...
elbillaf's user avatar
  • 1,994
2 votes
3 answers
1k views

Best way to substitute empty string for DBNull?

If a column in a DataRow might be DBNull, is the following the shortest way to substitute an empty string for DBNull? Dim result As String = if(isDBNull(dataRow1("column1")), "", dataRow1("column1"))
CJ7's user avatar
  • 23.3k
4 votes
4 answers
27k views

avoid checking for DataRow.IsDBNull on each column?

My code is 2x longer than it would be if I could automatically set IsDBNull to "" or simply roll over it without an error. This is my code: Dim conn As New SqlConnection conn.ConnectionString = ...
user avatar
0 votes
2 answers
5k views

DataRow type is DBNull

private DataRow getDataRowFromReader(IDataReader reader) { DataRow row = new DataRow(); DataTable tbl = new DataTable(); for (int i = 0; i < reader.FieldCount; i++) { Type ...
Ksice's user avatar
  • 3,327
17 votes
4 answers
29k views

Finding null value in Dataset - DataRow.IsNull method vs ==DbNull.Value - c#

What are the benefits of using the c# method DataRow.IsNull to determine a null value over checking if the row equals DbNull.value? if(ds.Tables[0].Rows[0].IsNull("ROWNAME")) {do stuff} vs if(ds....
Jarrod's user avatar
  • 1,555
8 votes
3 answers
22k views

How can I assign a DBNull in a better way?

I need to parse a value from a DataRow and assign it to another DataRow. If the input is valid, then I need to parse it to a double, or else add a DBNull value to the output. I'm using the following ...
Mike's user avatar
  • 3,304