C# datareadeer return null
C#
// ****** Use MySqlDataReader instead of SqlReader if you are using MySQL *******
//You need to check for IsDBNull:
//That's your only reliable way to detect and handle this situation.
//I wrapped those things into extension methods and tend to return a default value
//if the column is indeed null:
public static string SafeGetString(this SqlDataReader reader, int colIndex)
{
if(!reader.IsDBNull(colIndex))
return reader.GetString(colIndex);
return string.Empty;
}
//Now you can call it like this:
employee.FirstName = SqlReader.SafeGetString(indexFirstName);
// and you'll never have to worry about an exception or a null value again.
Also in C#:
- Title
- c# set textbox text
- Category
- C#
- Title
- unity getkey keycode
- Category
- C#
- Title
- c# enum default
- Category
- C#
- Title
- c# image to byte array
- Category
- C#
- Title
- unity 2d Drag object
- Category
- C#
- Title
- unity key detection
- Category
- C#
- Title
- unity fall damage c#
- Category
- C#
- Title
- unity array of child objects
- Category
- C#
- Title
- how to add a list to observablecollection in c#
- Category
- C#
- Title
- convert system.byte a string c#
- Category
- C#
- Title
- how to add object in dictionary in c#
- Category
- C#
- Title
- itext7 pdfwriter outputstream c#
- Category
- C#
- Title
- c# Authorization has been denied for this request
- Category
- C#
- Title
- run async methods within a sync process
- Category
- C#
- Title
- countdown script unity
- Category
- C#
- Title
- c# how to refreshyour bindingsource
- Category
- C#
- Title
- C# .NET Core linq Distinct
- Category
- C#
- Title
- unity deactive all object in list
- Category
- C#
- Title
- c# keyvaluepair
- Category
- C#
- Title
- reload current scene unity
- Category
- C#
- Title
- transform.Translate movement
- Category
- C#
- Title
- c# array to list
- Category
- C#
- Title
- how to stream video from vlc in c#
- Category
- C#
- Title
- c# display image
- Category
- C#
- Title
- check distance to gameobject
- Category
- C#
- Title
- how to a equall to b in c#
- Category
- C#
- Title
- how to make if statement c#
- Category
- C#
- Title
- where keyword in c#
- Category
- C#
- Title
- c# datatable copy selected rows to another table
- Category
- C#
- Title
- max of array C#
- Category
- C#
- Title
- c# listview
- Category
- C#
- Title
- asp.net mvc 5 codefirst dropdown list
- Category
- C#
- Title
- how to split a string with strings in c#
- Category
- C#
- Title
- asp net mvc 5 return view from another controller
- Category
- C#
- Title
- c# creating exceptions
- Category
- C#
- Title
- how to make an object move in unity
- Category
- C#
- Title
- button color uwp c#
- Category
- C#
- Title
- get all child gameObject of gameObject C#
- Category
- C#
- Title
- how to join array indexes with comma in c#
- Category
- C#
- Title
- how to add an embedded resource in visual studio code
- Category
- C#
- Title
- unity print to console
- Category
- C#
- Title
- unity get list length
- Category
- C#
- Title
- disable a component unity
- Category
- C#
- Title
- c# print to console
- Category
- C#
- Title
- switch case c# range
- Category
- C#
- Title
- unity check when clicked on object
- Category
- C#
- Title
- c# check file exists
- Category
- C#
- Title
- populate combobox from array c#
- Category
- C#
- Title
- unity coroutine
- Category
- C#
- Title
- How to get the world position of the edge of an object?
- Category
- C#
- Title
- how to do a messagebox in c#
- Category
- C#
- Title
- unity to integer
- Category
- C#
- Title
- list.addrange in c#
- Category
- C#
- Title
- idbset sqlquery
- Category
- C#
- Title
- c# how to compare 2 dates without time
- Category
- C#
- Title
- c# change colour of console
- Category
- C#
- Title
- 2d object look at object
- Category
- C#
- Title
- list clone - C#
- Category
- C#
- Title
- how to get specific length of row in matrix c#
- Category
- C#
- Title
- c# counting lines
- Category
- C#
- Title
- debug.log
- Category
- C#
- Title
- unity lerp
- Category
- C#
- Title
- c# float to string
- Category
- C#
- Title
- wpf c# select folder path
- Category
- C#
- Title
- find gameobject with tag
- Category
- C#
- Title
- unity c# run a command then wait
- Category
- C#
- Title
- example HttpClient c# Post
- Category
- C#
- Title
- how to name GameObject in c#
- Category
- C#
- Title
- unity set sprite transparency
- Category
- C#
- Title
- c# convert to int
- Category
- C#
- Title
- unity making homing missile
- Category
- C#
- Title
- c sharp if string equals
- Category
- C#
- Title
- c# windows application get current path
- Category
- C#
- Title
- c# uppercase string
- Category
- C#
- Title
- decimal to string whole number c#
- Category
- C#
- Title
- how to change text to bold through script unity
- Category
- C#
- Title
- define enum c#
- Category
- C#
- Title
- c# properties
- Category
- C#
- Title
- c# reverse string
- Category
- C#
- Title
- c# singleton
- Category
- C#
- Title
- how to change scenes in unity
- Category
- C#
- Title
- c# type of generic is string
- Category
- C#
- Title
- c# odd even median
- Category
- C#
- Title
- HashSet C# append
- Category
- C#
- Title
- Read csv file into wpf C#
- Category
- C#
- Title
- add row and columns to grid wpf in code
- Category
- C#
- Title
- convert string to double c#
- Category
- C#
- Title
- Unity if object doens't exist
- Category
- C#
- Title
- Execute code every x seconds with Update()
- Category
- C#
- Title
- c# tuple access
- Category
- C#
- Title
- downlaod file and use C#
- Category
- C#
- Title
- unity get data from firebase
- Category
- C#
- Title
- c sharp create dictionary
- Category
- C#
- Title
- unity if gameobject exists
- Category
- C#
- Title
- : ? conditioanl statement c#
- Category
- C#
- Title
- object escape player unity
- Category
- C#
- Title
- c sharp comments
- Category
- C#
- Title
- The type or namespace name 'Scrollbar' could not be found
- Category
- C#
- Title
- c# silent execute exe
- Category
- C#
- Title
- linq query select top 1 c#
- Category
- C#