0
Hello,
I need to create a table
within a DB Access
at runtime.
The Database already exists, I would just like to click on a button
a new table
was created within this DB
with Nome de Campos and Data Type all pre-defined, so that all new tables
are created with the same fields.
OleDbConnection ConSelect = new OleDbConnection();
ConSelect.ConnectionString = Properties.Settings.Default.dbteste;
ConSelect.Open();
OleDbCommand command = new OleDbCommand();
command.CommandText = "CREATE TABLE MyTable (" +
"[Count] INT NOT NULL AUTO_INCREMENT PRIMARY KEY ," +
"[TimeAndDate] TIMESTAMP NOT NULL ," +
"[SerialNumber] VARCHAR( 14 ) NOT NULL ," +
"[Result] BOOL NOT NULL ," +
"UNIQUE ([TimeAndDate]))";
command.ExecuteNonQuery();
ConSelect.Close();
This is a way I was trying, but still of error. -> Additional information: Executenonquery: Connection Property has not been initialized. <-
What have you done? What is your specific difficulty?
– Maniero
@Currently in my company, every sale I make, I make the
INSERT
of each product sold. (Within oneDB
, I have aTbVendas
, where I do all theINSERTs
). Now I need to create a new oneTable
for each sale made. (In an Evento_click, Create atbVendas2508
Within aDB
with the Fields already predefined. (Automatic_cod, Descprod, Precoprod... ) and then do theINSERT
inside that newTable
. About this problem I have nothing yet, Work with direct access to bank in Oledb, Access.– Maurício Sanches
What will this help in your application? And post what you’ve already done.
– Marco Souza
@GOKUSSJ4 When making the products out of my stock, I need to add them to a output note. so I’d like to create this
Tb
to use it as his own output note. So it needs to be inRunTime
, so that each time necessary to create a Output note I can create a newTable
.– Maurício Sanches
Why can’t you leave the Notes table created and do the Insert in it ? which forces you to create a table?
– Intruso
@Intruder I work with Auto Parts Export, I live in Miami and send to Brazil. Every week I make a Outgoing Note with about 1200 items, or about 800
Rows
. At the end of only 1 year would be more than 150milRows
in aTABLE
. I find a lot to do a research or a migration if one day it is necessary. That’s why I wanted to separate oneTABLE
for each Note. I can even think of creating aTABLE
for each month, to become lighter, but still, would need to create inRunTime
... But Thanks for your attention, I got the code and put as response. Hugs!– Maurício Sanches