Click here to Skip to main content
15,917,005 members
Home / Discussions / C#
   

C#

 
GeneralRe: What's The Best Way To Do This? Pin
Rob Philpott1-Nov-17 3:04
Rob Philpott1-Nov-17 3:04 
GeneralRe: What's The Best Way To Do This? Pin
peterkmx2-Nov-17 3:49
professionalpeterkmx2-Nov-17 3:49 
GeneralRe: What's The Best Way To Do This? Pin
Gerry Schmitz2-Nov-17 5:31
mveGerry Schmitz2-Nov-17 5:31 
AnswerRe: What's The Best Way To Do This? Pin
Pete O'Hanlon31-Oct-17 21:45
mvePete O'Hanlon31-Oct-17 21:45 
GeneralRe: What's The Best Way To Do This? Pin
Kevin Marois1-Nov-17 5:43
professionalKevin Marois1-Nov-17 5:43 
GeneralRe: What's The Best Way To Do This? Pin
Pete O'Hanlon1-Nov-17 5:59
mvePete O'Hanlon1-Nov-17 5:59 
AnswerRe: What's The Best Way To Do This? Pin
Nathan Minier1-Nov-17 1:36
professionalNathan Minier1-Nov-17 1:36 
SuggestionRe: What's The Best Way To Do This? Pin
Sascha Lefèvre1-Nov-17 2:01
professionalSascha Lefèvre1-Nov-17 2:01 
GeneralRe: What's The Best Way To Do This? Pin
Nathan Minier1-Nov-17 2:34
professionalNathan Minier1-Nov-17 2:34 
QuestionRe: What's The Best Way To Do This? Pin
Eddy Vluggen1-Nov-17 10:19
professionalEddy Vluggen1-Nov-17 10:19 
AnswerRe: What's The Best Way To Do This? Pin
Wendelius1-Nov-17 10:51
mentorWendelius1-Nov-17 10:51 
QuestionNext generics Problem Pin
Kevin Marois31-Oct-17 6:03
professionalKevin Marois31-Oct-17 6:03 
AnswerRe: Next generics Problem Pin
harold aptroot31-Oct-17 6:11
harold aptroot31-Oct-17 6:11 
GeneralRe: Next generics Problem Pin
Kevin Marois31-Oct-17 6:25
professionalKevin Marois31-Oct-17 6:25 
QuestionHow To Make This Generic Pin
Kevin Marois31-Oct-17 5:02
professionalKevin Marois31-Oct-17 5:02 
AnswerRe: How To Make This Generic Pin
Sascha Lefèvre31-Oct-17 5:43
professionalSascha Lefèvre31-Oct-17 5:43 
GeneralRe: How To Make This Generic Pin
Kevin Marois31-Oct-17 5:55
professionalKevin Marois31-Oct-17 5:55 
QuestionWPF assembly in C# Pin
Benjamin Bruno30-Oct-17 19:36
Benjamin Bruno30-Oct-17 19:36 
AnswerRe: WPF assembly in C# Pin
Mycroft Holmes30-Oct-17 20:30
professionalMycroft Holmes30-Oct-17 20:30 
AnswerRe: WPF assembly in C# Pin
Pete O'Hanlon30-Oct-17 20:31
mvePete O'Hanlon30-Oct-17 20:31 
AnswerRe: WPF assembly in C# Pin
OriginalGriff30-Oct-17 20:37
mveOriginalGriff30-Oct-17 20:37 
AnswerRe: WPF assembly in C# Pin
Gerry Schmitz31-Oct-17 12:17
mveGerry Schmitz31-Oct-17 12:17 
GeneralRe: WPF assembly in C# Pin
peterkmx2-Nov-17 6:29
professionalpeterkmx2-Nov-17 6:29 
QuestionEnum of C# Data Types - byte[] and char[] Pin
Kevin Marois30-Oct-17 12:30
professionalKevin Marois30-Oct-17 12:30 
I'm working on a type converter for .Net to Sql and .Net to OleDb.

First, I create a class called DataType:
public class DataType
{
    public DotNetTypes? DotNetType { get; private set; }
    public SqlDbType? SqlDbType { get; private set; }
    public OleDbType? OleDbType { get; private set; }

    public DataType(DotNetTypes? dotNetType, SqlDbType? sqlDbType, OleDbType? oleDbType)
    {
        DotNetType = dotNetType;
        SqlDbType = sqlDbType;
        OleDbType = oleDbType;
    }
}

Next I load it like this:
private static List<DataType> DataTypes;

static DataTypeConversion()
{
    Load();
}

private static void Load()
{
    DataTypes = new List<DataType>
    {
        new DataType(DotNetTypes.Short, SqlDbType.SmallInt, null),
        new DataType(DotNetTypes.Int32, SqlDbType.Int, null),
        new DataType(DotNetTypes.Int64, SqlDbType.BigInt, null),
        new DataType(DotNetTypes.Boolean, SqlDbType.Bit, null),
        new DataType(DotNetTypes.Double, SqlDbType.Float, null),
        new DataType(DotNetTypes.Float, SqlDbType.Real, null),
        new DataType(DotNetTypes.Guid, SqlDbType.UniqueIdentifier, null),
        new DataType(DotNetTypes.Byte, SqlDbType.TinyInt, null),
        new DataType(DotNetTypes.DataTable, SqlDbType.Structured, null),

        new DataType(DotNetTypes.DateTime, SqlDbType.DateTime, null),
        new DataType(DotNetTypes.DateTime, SqlDbType.SmallDateTime, null),
        new DataType(DotNetTypes.DateTime, SqlDbType.Date, null),
        new DataType(DotNetTypes.DateTime, SqlDbType.Time, null),
        new DataType(DotNetTypes.DateTime, SqlDbType.DateTime2, null),

        new DataType(DotNetTypes.DateTimeOffset, SqlDbType.DateTimeOffset, null),

        new DataType(DotNetTypes.Object, SqlDbType.Variant, null),
        new DataType(DotNetTypes.Object, SqlDbType.Udt, null),

        new DataType(DotNetTypes.Decimal, SqlDbType.Decimal, null),
        new DataType(DotNetTypes.Decimal, SqlDbType.Money, null),
        new DataType(DotNetTypes.Decimal, SqlDbType.SmallMoney, null),

        new DataType(DotNetTypes.Byte, SqlDbType.Binary, null),
        new DataType(DotNetTypes.Byte, SqlDbType.Image, null),
        new DataType(DotNetTypes.Byte, SqlDbType.VarBinary, null),
        new DataType(DotNetTypes.Byte, SqlDbType.Timestamp, null),

        new DataType(DotNetTypes.String, SqlDbType.NVarChar, null),
        new DataType(DotNetTypes.String, SqlDbType.VarChar, null),
        new DataType(DotNetTypes.String, SqlDbType.Char, null),
        new DataType(DotNetTypes.String, SqlDbType.NChar, null),
        new DataType(DotNetTypes.String, SqlDbType.NText, null),
        new DataType(DotNetTypes.String, SqlDbType.Text, null),
        new DataType(DotNetTypes.String, SqlDbType.Xml, null)
    };
}
To do this I created an enum called DotNetTypes:
public enum DotNetTypes
{
    @Unknown,
    @Short,
    @Boolean,
    @Byte,
    @Char,
    @DateTime,
    @DateTimeOffset,
    @Decimal,
    @Double,
    @Int32,
    @Int16,
    @Int64,
    @Float,
    @Object,
    @SByte,
    @Single,
    @String,
    @UInt16,
    @UInt32,
    @UInt64,
    @Guid,
    @DataTable
}

Notice that in the Load method I have
new DataType(DotNetTypes.Byte, SqlDbType.Binary, null),
new DataType(DotNetTypes.Byte, SqlDbType.Image, null),
new DataType(DotNetTypes.Byte, SqlDbType.VarBinary, null),
new DataType(DotNetTypes.Byte, SqlDbType.Timestamp, null),
The problem is that these should be byte arrays, not byte. So what is the syntax for this in my DotNetTypes enum?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

GeneralRe: Enum of C# Data Types - byte[] and char[] Pin
Sascha Lefèvre30-Oct-17 14:06
professionalSascha Lefèvre30-Oct-17 14:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.