I am trying to develop a class that I can use to create table/columns in SQLite dynamically; I have created my class as follow:
public class NewColumns
{
public string ClmName;
public Types NewType { get; set; }
public void SetName(string NewColumn)
{
ClmName = NewColumn;
}
}
public enum Types
{
INTEGER = 0,
REAL = 1,
NUMERIC = 2,
TEXT = 3,
BLOB = 4,
}
public static bool CreateTable(string DBPath, string TableName, params NewColumns ClumnName)
{
bool succ = false;
mDBcon.ConnectionString = "Data Source=" + DBPath + ".db3";
mDBcon.Open();
cmd = new SQLiteCommand(mDBcon);
cmd.CommandText = "CREATE TABLE IF NOT EXISTS " + TableName + " (ISBN VARCHAR(15), Tag VARCHAR(15));";
cmd.ExecuteNonQuery();
return succ;
}
I would like to pass my new values to the class like this:
clsSqlite.CreateTable("test", "newTable", new clsSqlite.NewColumns { ClmName = "", NewType.INTEGER });
But the “NewType” on the code above not recognising my enum Values and its give me the following error if I type the enum value ‘INTEGER’ manually:
Invalid initializer member declaratory
Thanks in advance for the help.
Regards,
NewTypeis the name of your property, the enum is calledTypes