ConfusedNewby
Programmer
I am very new to OO and C#.
I want to write a method which returns a String. It will accept arguments a
tablename(string) a collection of Structs (hope this is a better option than class) and a parameter indicating whether to generate an insert or an update (char).
The Struct definition is :-
public struct FieldDef{
public String _FieldName;
public Char _FieldType;
public Boolean _IsID;
}
where Fieldname is just a name and FieldType is a character indicating
String/Integer/etc.
The method should take the given collection and output an SQL statement
of the format
"Insert into _Invoice (cInvoiceCode, dInvoiceDate, cInvoiceCust, iInvoiceAmt)
values ('{0}', '{1}', '{2}', {3})"
or
"Update _Invoice set cInvoiceCode='{0}', dInvoiceDate='{1}',
cInvoiceCust='{2}', iInvoiceAmt={3} where iIdInvoice={4}"
I want to use the fieldtype to determine whether to enclose the format
specifiers in quotes or not.
How do I get to the best solution.
Tried an ArrayList, but it doesn't seem to work that well...
Thanks
I want to write a method which returns a String. It will accept arguments a
tablename(string) a collection of Structs (hope this is a better option than class) and a parameter indicating whether to generate an insert or an update (char).
The Struct definition is :-
public struct FieldDef{
public String _FieldName;
public Char _FieldType;
public Boolean _IsID;
}
where Fieldname is just a name and FieldType is a character indicating
String/Integer/etc.
The method should take the given collection and output an SQL statement
of the format
"Insert into _Invoice (cInvoiceCode, dInvoiceDate, cInvoiceCust, iInvoiceAmt)
values ('{0}', '{1}', '{2}', {3})"
or
"Update _Invoice set cInvoiceCode='{0}', dInvoiceDate='{1}',
cInvoiceCust='{2}', iInvoiceAmt={3} where iIdInvoice={4}"
I want to use the fieldtype to determine whether to enclose the format
specifiers in quotes or not.
How do I get to the best solution.
Tried an ArrayList, but it doesn't seem to work that well...
Thanks