devxlogo

GetOleDbType – Retrieving the OleDbType for the specified system type

GetOleDbType – Retrieving the OleDbType for the specified system type

' Return the OleDbType that represents the specified system type' This is particularly useful when you have a DataTable and want to create a ' OleDbParameter for onw of its columns, but don't know its type. ' DataColumnName.DataType returns a Type, and you can convert it to OleDbType ' by passing it to this function.' Note: requires System.Data.OleDb' Example:'   Dim param As New OleDbParameter("TestCol", GetOleDbType(String))Private Function GetOleDbType(ByVal sysType As Type) As OleDbType    If sysType Is GetType(String) Then        Return OleDbType.VarChar    ElseIf sysType Is GetType(Integer) Then        Return OleDbType.Integer    ElseIf sysType Is GetType(Boolean) Then        Return OleDbType.Boolean    ElseIf sysType Is GetType(Date) Then        Return OleDbType.Date    ElseIf sysType Is GetType(Char) Then        Return OleDbType.Char    ElseIf sysType Is GetType(Decimal) Then        Return OleDbType.Decimal    ElseIf sysType Is GetType(Double) Then        Return OleDbType.Double    ElseIf sysType Is GetType(Single) Then        Return OleDbType.Single    ElseIf sysType Is GetType(Byte()) Then        Return OleDbType.Binary    ElseIf sysType Is GetType(Guid) Then        Return OleDbType.Guid    End IfEnd Function

See also  Redefining Energy Management: Advanced Solutions for Modern Buildings
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist