Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataType for VarChar
Message
From
31/03/2014 17:23:37
 
General information
Forum:
ASP.NET
Category:
Databases
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01597800
Message ID:
01597804
Views:
40
>There is SqlDbType.VarChar data type, but System.String type. So, for all char data it will be System.String type.

Well, this causes a problem, as when I use a database which is not bound to my data dictionary, I need to rely on what the DataTable will return. So, I need to be able to differentiate between a string and a varchar.

For example, this is a method I have that I call when I need to know the data type of a column, if I do not have my data dictionary to rely on. This assumes oDataTable is already available. So, I pass the field, in this case a column formely known in SQL Server, and the property I need to get info from. So, the one that is of interest here is DataType. So, I can call the method here with "FirstName", "DataType" and this will return System.String, for example, if FirstName is a column of type Character in SQL Server. But, I need a way to differentiate that from a VarChar. This seems impossible I would assume.
    ' Return a property of a field
    ' expC1 Field
    Public Function GetColumnProperty(ByVal tcField As String, ByVal tcProperty As String) As Object
        Dim lcFieldName As String = ""
        Dim loRow As DataRow = Nothing

        ' Trim just in case
        tcField = Trim(tcField)

        ' Locate the field
        For Each loRow In oDataTable.Rows
            lcFieldName = loRow("ColumnName")

            ' If this is the field
            If UCase(lcFieldName) = UCase(tcField) Then

                ' This is an example to get the type for the column
                lcType = loRow("DataType")

            End If

        Next
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform