This question is locked. New answers and comments are not allowed.
Hi,
I have just started looking into using the Open Access ORM and currently have the following set-up on my form.
This works ok if i'm just updating a value in the table but if i add a new row or delete a row i get the following Excpetion:
I seems to have duplicated some of my Columns. Could this be something to do with my Foreign Keys?
Thanks
I have just started looking into using the Open Access ORM and currently have the following set-up on my form.
Context dbcontext =
new
Context();
Void LoadData()
{
var T001 =
new
ObservableCollection<T001_Table>(dbcontext.T001_Table.Where(p => p.Group_Code == (
int
)comboBox1.SelectedValue));
T001.CollectionChanged +=
new
NotifyCollectionChangedEventHandler(T001_CollectionChanged);
this
.dataGridView1.DataSource =
new
BindingSource() { DataSource = T001 };
}
void
T001_CollectionChanged(
object
sender, NotifyCollectionChangedEventArgs e)
{
if
(e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
dbcontext.Add(e.NewItems);
if
(e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
dbcontext.Delete(e.OldItems);
}
private
void
button1_Click(
object
sender, EventArgs e)
{
if
(MessageBox.Show(
this
,
"Save Changes?"
,
"Save Changes?"
, MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
{
try
{
dbcontext.SaveChanges();
MessageBox.Show(
"Data Saved"
);
}
catch
(Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
This works ok if i'm just updating a value in the table but if i add a new row or delete a row i get the following Excpetion:
Insert
of
'1361221285-'
failed: Telerik.OpenAccess.RT.sql.SQLException: Invalid
column
name
'ColumnA2'
.
Invalid
column
name
'ColumnB2'
.
Invalid
column
name
'ColumnC2'
.
Invalid
column
name
'ColumnD2'
.
Invalid
column
name
'ColumnE2'
.
Invalid
column
name
'ColumnF2'
.
Statement(s) could
not
be prepared.
at
Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.
execute
()
at
OpenAccessRuntime.Relational.conn.PooledPreparedStatement.
execute
()
at
OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32
index
, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes)
INSERT
INTO
[T001_Table] ([ColumnA], [ColumnB], [ColumnC], [ColumnD], [ColumnE], [ColumnF], [ColumnG], [ColumnH], [ColumnI], [ColumnJ], [ColumnK], [ColumnL], [ColumnN], [ColumnO], [ColumnP], [ColumnQ], [ColumnR], [ColumnS], [ColumnT], [UColumn], [ColumnA2], [ColumnB2], [ColumnC2], [ColumnD2], [ColumnE2], [ColumnF2], [ColumnU], [ColumnV], [ColumnW], [ColumnX], [ColumnY], [ColumnZ])
VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
select
scope_identity()
(
set
event logging
to
all
to
see parameter
values
) Telerik.OpenAccess.RT.sql.SQLException: Invalid
column
name
'ColumnA2'
.
Invalid
column
name
'ColumnB2'
.
Invalid
column
name
'ColumnC2'
.
Invalid
column
name
'ColumnD2'
.
Invalid
column
name
'ColumnE2'
.
Invalid
column
name
'ColumnF2'
.
Statement(s) could
not
be prepared.
at
Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.
execute
()
at
OpenAccessRuntime.Relational.conn.PooledPreparedStatement.
execute
()
at
OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32
index
, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes)
I seems to have duplicated some of my Columns. Could this be something to do with my Foreign Keys?
Thanks