dbnull Questions

13

Solved

I'm trying to execute a stored procedure and then use an if statement to check for null values and I'm coming up short. I'm a VB guy so please bear with me if I'm making a schoolboy syntax error. ...
Powys asked 3/5, 2012 at 12:55

3

Solved

I get this exception when I try to insert a DBNull.Value into a nullable varbinary(max) field: Implicit conversion from data type nvarchar to varbinary(max) is not allowed. Use the CONVERT functio...
Keister asked 10/7, 2012 at 10:58

14

Solved

I want to generate some formatted output of data retrieved from an MS-Access database and stored in a DataTable object/variable, myDataTable. However, some of the fields in myDataTable cotain dbNul...
David asked 21/10, 2008 at 18:3

20

Solved

The following code gives an error - "No implicit conversion from DBnull to int." SqlParameter[] parameters = new SqlParameter[1]; SqlParameter planIndexParameter = new SqlParameter("@AgeIndex", S...
Hamadryad asked 29/12, 2010 at 16:42

5

Solved

I'm looking for a simpler way to check if a value is dbNull and to convert it to an empty string if so. An example of a situation where I need this would be: Dim dt As New DataTable Dim conn As ...
Abscess asked 28/10, 2015 at 20:26

9

Solved

How can I check for a NULL value in an open MySqlDataReader? The following doesn't work; it's always hitting the else: if (rdr.GetString("timeOut") == null) { queryResult.Egresstime = "Logged in...
Immortality asked 19/1, 2011 at 19:19

6

Solved

In .NET there is the null reference, which is used everywhere to denote that an object reference is empty, and then there is the DBNull, which is used by database drivers (and few others) to denote...
Finny asked 20/12, 2010 at 10:25

4

Solved

I got this parameter: $objDbCmd.Parameters.Add("@telephone", [System.Data.SqlDbType]::VarChar, 18) | Out-Null; $objDbCmd.Parameters["@telephone"].Value = $objUser.Telephone; Where the string $ob...
Iowa asked 28/5, 2009 at 14:0

8

Solved

i am receiving this problem Conversion from type 'DBNull' to type 'String' is not valid. Line 501: hfSupEmail.Value = dt.Rows(0)("SupEmail") i am very new to this, i am not really sure wh...
Delaunay asked 25/4, 2014 at 2:52

7

EDIT: As of PowerShell 7 Preview 2, -not [System.DBNull]::Value evaluates to $true, thanks to Joel Sallow via pull request 9794 Spending more time pulling SQL data in PowerShell. Running into issue...
Petronius asked 9/3, 2014 at 17:1

5

Solved

I have the following C# code: sqlCommand.Parameters.AddWithValue("@Parameter", table.Value ?? DBNull.Value); But it throws the following compilation error: Operator ?? cannot be applied to op...
Signalment asked 11/11, 2010 at 9:37

6

Solved

I have seen many, many versions of this on SO, but none of them seem to quite work for my needs. My data comes from a vendor database that allows null for DateTime fields. First I pull my data in...
Ilmenite asked 20/10, 2010 at 14:16

6

Solved

I'd like to avoid having many checks like the following in my code: myObj.someStringField = rdr.IsDBNull(someOrdinal) ? string.Empty : rdr.GetString(someOrdinal); I figured I could just have...
Achaean asked 28/4, 2009 at 18:57

5

Solved

I had this interesting discussion today with a colleague. We were debating two pieces of code in C#. Code Snippet 1: if(!reader.IsDBNull(2)) { long? variable1 = reader.GetInt64(2) } Code Snip...
Mccrory asked 17/5, 2012 at 10:26

6

Solved

How can I add a null value in a parameter varbinary datatype? When I execute the following code: using (SqlConnection myDatabaseConnection1 = new SqlConnection(myConnectionString.ConnectionString...
Affiliation asked 11/8, 2013 at 10:28

3

Solved

I want to retrieve decimal values from the database and I would like to know which is the recommended way to check for null values. I have seen on MSDN - DBNull.Value Field that this check is rar...
False asked 31/8, 2013 at 17:15

4

Solved

I can check for a DBnull on a data row using any of the methods. Either by using if(dr[0][0]==DBNull.Value) //do somethin or by doing if(dr[0][0].ToString().IsNullOrEmpty()) //do something ...
Lightning asked 3/8, 2010 at 6:6

4

Solved

sdr is my sqldatareader and I want to check that the curPrice value which is of type decimal is null. inrec.curPrice = sdr.IsDBNull(7) ? (decimal?)null : sdr.GetDecimal(7); This is the error mes...
Speedway asked 9/5, 2012 at 20:50

3

Solved

I am curious what are the pros and cons of using if(some_value is DBNull) versus if(DBNull.Value.Equals(some_value)). Personally i prefer if(some_value is DBNull) because i find it more readable. I...
Moxie asked 14/7, 2016 at 12:6

2

Solved

Before anyone comments that this has been answered before in other question I KNOW that..but in spite of the answers I have reviewed at Assign null to a SqlParameter Sending null parameters to Sq...
Midtown asked 27/5, 2016 at 21:6

5

Solved

(LocalVariable)ABC.string(Name) = (IDataReader)dataReader.GetString(0); This name value is coming from database. What happening here is if this name is null while reading it's throwing an exceptio...
Outwash asked 9/4, 2010 at 18:26

8

Solved

I need some expect advice on how to handle the following:- I have a data field misc_text_2 that is of type varchar(25) and allows NULL. Now if I use the following syntax <asp:Label ID="lblPrint...
Hereof asked 11/2, 2009 at 10:16

6

Solved

I've got a DateTime? that I'm trying to insert into a field using a DbParameter. I'm creating the parameter like so: DbParameter datePrm = updateStmt.CreateParameter(); datePrm.ParameterName = "@c...
Roderich asked 20/10, 2008 at 15:23

4

Solved

It seems that there's some type confusion in the ternary operator. I know that this has been addressed in other SO threads, but it's always been with nullables. Also, for my case I'm really just lo...
Plow asked 9/8, 2010 at 22:54

3

Solved

I'm trying to add a column to an existing DataRow in C#. Afterwards the column will be filled with a single value from my database. DataRow dr already exists and column "COLNAME" also exists. comT...
Mindexpanding asked 28/10, 2011 at 9:6

© 2022 - 2024 — McMap. All rights reserved.