datatable - DataRow ArrayItem's DataType for NULL Values vb.net -


I am passing through a scenario where I have dataable and there are many types of columns, I have to filter the data The type of null value column, so I can provide some default value to it, now there is nothing to trap it in. There is a code for testing below.

  Public Class form 1 private sub form 1_load (as a sub-sender, object and system in system form. Avent ARG) are MyBase. Datatyll = GetTable () 'as Lead Dim Table' 'We can instantiate a new object array and add it as a line', as the line line = Detorau = table. RAW (1) for each item in the form of the item in the row. ItemArray If TypeOf object is integer, then the console WrightLine ("Int: {0}", item) ElseIf TypeOf item is string then console WriteLine ("string: {0}", item) Alsef typewrite item is the TimeTime Time Console.Vitalline ("Datetime: {0}", item) Alsef typeoff item is system. Debnail then consoles ("dbnl {0}") if the end-end sub-private shared function GetTable () DataTable as 'table here' table (table) as we create a DataTable table with four columns. Columns Add ("ID", GetType (integer) table. Add columns. ("Name", GetType (string)) table. Columns Add ("Desc", GetType (String) table. Column.ed ("Date", Gettimes) Here we add five Datasrovers. Table Rows. Add (1, "ABC", "Cool Down", Datetime.) Now Table. Rouse Return the table end function   

and class

I'm just going to the null value column row (2, "Chenono", "Haliffer", dBBill Value) It shows "System.DBNull" for the date column. I have to understand the datatype of this column.

I have come to know how to work with specific columns. Two methods 1: column name 2 : Or, from the index of that column and its datatype,

  as a dim row DataRow = table.Rows (1) dim index like integer = 0 in the form of an object for each object. ItemArray if the TypeOf item is integer then the console Wrightite ("Int: {0}", item) console. The light line ("Date time: {0}", item) is another type of item system. Debugn then console Type ("DBNULL {0}", item) if the table ends. Column (index) .ColumnName.Contains ("Date") Then 'stuff' (method 1) end if if the table. Column (index). Type the data. Toastring () = "System.Detime" then 'Contents {Method 2} End if Index = Pointer + 1 Next    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -