dbnull Questions

3

Solved

The stored procedure for command can return null.Is it correct way to check if the returned value is null or should I also check that obj is null? object obj = command.ExecuteScalar(); int id = -1...
Bridging asked 15/1, 2014 at 9:44

2

Solved

I have the follwoing code that performs a query and returns a result. However, I looked around and found some examples to take care of null values but I get an error: "Invalid attempt to read when ...
Involution asked 31/12, 2013 at 19:57

4

Solved

I frequently have to deal with DataTables connected to grid controls, custom updating always seems to produce a lot of code related to DBNull.Value. I saw a similar question here but think there mu...
Ungulate asked 17/8, 2010 at 9:54

3

Solved

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 followin...
Utter asked 17/2, 2011 at 7:7

7

If in VB.NET I have DataRow and I want to test whether a column value is Null, should I use: myDataRow.IsNull("Column1") OR IsDBNull(myDataRow("Column1"))
Arvillaarvin asked 9/7, 2013 at 12:21

6

Solved

I am using a dataset to pull data from a DB. One of the fields in a row is NULL. I know this. However, the following vb.net code throws a StrongTypingException (in the autogenerated get_SomeField()...
Kilmarx asked 14/1, 2011 at 9:29

4

Solved

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 = M...
Ruvalcaba asked 18/1, 2013 at 14:43

3

Solved

I have two DateTime objects, BirthDate and HireDate. They are correctly formatted as a string and when I pass them through to my data access layer, they need to be parsed into a DateTime object. ...
Tetravalent asked 25/11, 2012 at 21:6

3

Solved

I have some textboxes on my page which can be empty because they are optional and I have this DAL code parameters.Add(new SqlParameter("@FirstName", FirstName)); parameters.Add(new SqlParame...
Zoophobia asked 16/9, 2012 at 2:56

4

I'm getting an error when selecting from a rows.AsEnumerable(). I am using the following code... var rows = ds.Tables[0].AsEnumerable(); trafficData = rows.Select(row => new tdDataDC { Calc...
Squarely asked 29/6, 2010 at 23:13

6

Solved

Is there any difference between null and System.DBNull.Value? If yes, what is it? I noticed this behavior now - while (rdr.Read()) { if (rdr["Id"] != null) //if (rdr["Id"] != System.DBNull.Valu...
Genetic asked 10/2, 2011 at 14:33

2

Solved

Why does the following query raise the error below for a row with a NULL value for barrel when I explicitly filter out those rows in the Where clause? Dim query = From row As dbDataSet.conformalRo...
Iapetus asked 8/3, 2010 at 16:43

9

Solved

I have a table which contains null values and I need to get data from the table using SqlDataReader. I can't figure out how I can safely cast DBNull to int. I'm doing it in this way at the moment:...
Halsted asked 21/2, 2012 at 12:35

1

Solved

I'm using the SQL Express 2010 query builder. I need to be able to increment a field. In my behind code, I make a call such as tableAdapter.IncrementLikeCount(id); If I just use an increment, t...
Byrnes asked 3/2, 2012 at 22:42

2

Solved

I want to create a stored procedure (in SQL Server 2008 R2) that will update a record in a table based on the table's PK. The stored proc will have, for example, four parameters: @ID int, @Name n...
Brendon asked 12/8, 2011 at 17:2

8

Solved

I'm trying to populate a class object with values from a database table. The someObject.Property field is a nullable int type. someObject.Property = Convert.ToInt32(dbReader["SomeField"]); So, i...
Ralfston asked 19/5, 2011 at 16:55

1

Solved

I have a Product table with non-null "quantity" (decimal) and "status" (int) columns, and I created a view on this table with the following case expression: SELECT P.ProductTypeId, (CASE WHEN P.S...
Kruse asked 17/5, 2011 at 16:56

4

Solved

I understand that the SQL standard allows multiple NULL values in a column that is part of the UNIQUE constraint. What I don't understand is why the UNION construct (at least in PostgreSQL,) treat...
Supporter asked 20/4, 2011 at 2:50

4

Solved

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(d...
Misapply asked 8/4, 2011 at 18:38

2

Solved

I want to return all rows from a SQL Server 2008 database table into a SQL data source if a textBox field is blank. So I made a stored procedure with an if @date IS NULL clause. Although the stor...
Carpometacarpus asked 21/2, 2011 at 15:51

2

Solved

I use OleDB to read an Excel file. One of the columns has a "Common" format and contains both strings with letters and values consisting of numbers only. String values are retrieved without problem...
Huttan asked 8/7, 2010 at 18:48

2

I'm using a SQL Server 2008 stored procedure to create a new record with this syntax: cmd.Parameters.Add("@photo", DBNull.Value) cmd.ExecuteNonQuery() but the result is a: Operand type clash...
Coexist asked 10/3, 2010 at 21:23

3

Solved

I have defined Class Person property Birthday as nullable DateTime? , so why shouldn’t the null coalescing operator work in the following example? cmd.Parameters.Add(new SqlParameter("@Birthday",...
Thirddegree asked 6/8, 2010 at 15:22

13

Is there a better/cleaner way to do this? int stockvalue = 0; if (!Convert.IsDBNull(reader["StockValue"])) stockvalue = (int)reader["StockValue"];
Lizbeth asked 12/3, 2010 at 13:56

2

Solved

I have the following code foreach (DataRowView dr in Data) { if (dr == System.DBNull.Value) { nedID = 1; } } but i get the following error Operator == cannot be applied to operands of type...
Elidaelidad asked 23/3, 2010 at 16:11

© 2022 - 2024 — McMap. All rights reserved.