By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,635 Members | 1,699 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,635 IT Pros & Developers. It's quick & easy.

Error updating new column...!

P: n/a
My table has 5 columns: Broj iksice, Prezime, Ime, Broj indeksa, Broj
pohadjanja.
This is the code in the dataset designer VB made it by it self:

Private Sub InitClass()
Me.columnBroj_iksice = New System.Data.DataColumn("Broj iksice",
GetType(Double), Nothing, System.Data.MappingType.Element)
Me.columnBroj_iksice.ExtendedProperties.Add("Gener ator_ColumnPropNameInRow",
"Broj_iksice")
Me.columnBroj_iksice.ExtendedProperties.Add("Gener ator_ColumnPropNameInTable",
"Broj_iksiceColumn")
Me.columnBroj_iksice.ExtendedProperties.Add("Gener ator_ColumnVarNameInTable",
"columnBroj_iksice")
Me.columnBroj_iksice.ExtendedProperties.Add("Gener ator_UserColumnName",
"Broj iksice")
MyBase.Columns.Add(Me.columnBroj_iksice)
Me.columnPrezime = New System.Data.DataColumn("Prezime",
GetType(String), Nothing, System.Data.MappingType.Element)
MyBase.Columns.Add(Me.columnPrezime)
Me.columnIme = New System.Data.DataColumn("Ime",
GetType(String), Nothing, System.Data.MappingType.Element)
MyBase.Columns.Add(Me.columnIme)
Me.columnBroj_indeksa = New System.Data.DataColumn("Broj
indeksa", GetType(String), Nothing, System.Data.MappingType.Element)
Me.columnBroj_indeksa.ExtendedProperties.Add("Gene rator_ColumnPropNameInRow",
"Broj_indeksa")
Me.columnBroj_indeksa.ExtendedProperties.Add("Gene rator_ColumnPropNameInTable",
"Broj_indeksaColumn")
Me.columnBroj_indeksa.ExtendedProperties.Add("Gene rator_ColumnVarNameInTable",
"columnBroj_indeksa")
Me.columnBroj_indeksa.ExtendedProperties.Add("Gene rator_UserColumnName",
"Broj indeksa")
MyBase.Columns.Add(Me.columnBroj_indeksa)
Me.columnBroj_pohadjanja = New System.Data.DataColumn("Broj
pohadjanja", GetType(Integer), Nothing, System.Data.MappingType.Element)
Me.columnBroj_pohadjanja.ExtendedProperties.Add("G enerator_ColumnPropNameInRow",
"Broj_pohadjanja")
Me.columnBroj_pohadjanja.ExtendedProperties.Add("G enerator_ColumnPropNameInTable",
"Broj_pohadjanjaColumn")
Me.columnBroj_pohadjanja.ExtendedProperties.Add("G enerator_ColumnVarNameInTable",
"columnBroj_pohadjanja")
Me.columnBroj_pohadjanja.ExtendedProperties.Add("G enerator_UserColumnName",
"Broj pohadjanja")
MyBase.Columns.Add(Me.columnBroj_pohadjanja)
Me.Constraints.Add(New
System.Data.UniqueConstraint("Constraint1", New System.Data.DataColumn()
{Me.columnBroj_iksice}, true))
Me.columnBroj_iksice.AllowDBNull = false
Me.columnBroj_iksice.Unique = true
Me.columnPrezime.MaxLength = 255
Me.columnIme.MaxLength = 255
Me.columnBroj_indeksa.MaxLength = 255
End Sub

I get an error when I add new column with this code:

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Dim noviStupac As Data.DataColumn = New Data.DataColumn("Test
Marko", System.Type.GetType("System.Int32"), Nothing,
System.Data.MappingType.Element)
noviStupac.AutoIncrement = False
noviStupac.DefaultValue = 0

Try
Form2.Studenti1Data.Tables.Item(Index(ComboBox1.Te xt)).Columns.Add(noviStupac)
'Dodaje stupac u tablicu

Form2.Studenti1Data.Tables.Item(Index(ComboBox1.Te xt)).AcceptChanges()

Form2.Table1DataGridView.AutoGenerateColumns = True 'Kada dodas
stupac da se prikaze u prozoru

Novo(Form2.Studenti1Data.Tables.Item(Index(ComboBo x1.Text)).TableName,
"Fill") 'Ponovo prikazuje tablicu u datom prozoru

Catch ex As Exception

MsgBox("Vec postoji dati stupac!", MsgBoxStyle.Exclamation,
"Upozorenje!")

End Try
End Sub

The error is:
System.Data.OleDb.OleDbException was unhandled
ErrorCode=-2147217887
Message="Cannot update 'TEST Marko'; field not updateable."
Source="Microsoft JET Database Engine"
StackTrace:
at
System.Data.Common.DbDataAdapter.UpdatedRowStatusE rrors(RowUpdatedEventArgs
rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at
System.Data.Common.DbDataAdapter.UpdatedRowStatus( RowUpdatedEventArgs
rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows,
DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.UpdateFromDataTab le(DataTable
dataTable, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataTable dataTable)
at Diplomski1.Form1.Novo(String nova1, String nova2) in
D:\OdMomka\Diplomski\Diplomski1\Diplomski1\Form1.v b:line 305
at Diplomski1.Form2.Table1BindingNavigatorSaveItem_Cl ick(Object
sender, EventArgs e) in
D:\OdMomka\Diplomski\Diplomski1\Diplomski1\Form2.v b:line 8
at System.Windows.Forms.ToolStripItem.RaiseEvent(Obje ct key,
EventArgs e)
at System.Windows.Forms.ToolStripButton.OnClick(Event Args e)
at System.Windows.Forms.ToolStripItem.HandleClick(Eve ntArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(M ouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventIntera ctive(EventArgs
e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(Event Args e,
ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEven tArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message&
m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG&
msg)
at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationCo ntext context)
at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.Run(String[]
commandLine)
at Diplomski1.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAss embly()
at
System.Runtime.Hosting.ApplicationActivator.Create Instance(ActivationContext
activationContext, String[] activationCustomData)
at
System.Runtime.Hosting.ApplicationActivator.Create Instance(ActivationContext
activationContext)
at
Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssemblyDebugInZone()
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

I didn't set autoincrement as true.
I dont know wat is wrong!
Can you help me...!
Jan 23 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Explode,

It is hard to see, but does your table have a primary key, and is it set?

Cor
"explode" <ur**@mzos.hrschreef in bericht
news:ep**********@news1.carnet.hr...
My table has 5 columns: Broj iksice, Prezime, Ime, Broj indeksa, Broj
pohadjanja.
This is the code in the dataset designer VB made it by it self:

Private Sub InitClass()
Me.columnBroj_iksice = New System.Data.DataColumn("Broj
iksice",
GetType(Double), Nothing, System.Data.MappingType.Element)

Me.columnBroj_iksice.ExtendedProperties.Add("Gener ator_ColumnPropNameInRow",
"Broj_iksice")

Me.columnBroj_iksice.ExtendedProperties.Add("Gener ator_ColumnPropNameInTable",
"Broj_iksiceColumn")

Me.columnBroj_iksice.ExtendedProperties.Add("Gener ator_ColumnVarNameInTable",
"columnBroj_iksice")

Me.columnBroj_iksice.ExtendedProperties.Add("Gener ator_UserColumnName",
"Broj iksice")
MyBase.Columns.Add(Me.columnBroj_iksice)
Me.columnPrezime = New System.Data.DataColumn("Prezime",
GetType(String), Nothing, System.Data.MappingType.Element)
MyBase.Columns.Add(Me.columnPrezime)
Me.columnIme = New System.Data.DataColumn("Ime",
GetType(String), Nothing, System.Data.MappingType.Element)
MyBase.Columns.Add(Me.columnIme)
Me.columnBroj_indeksa = New System.Data.DataColumn("Broj
indeksa", GetType(String), Nothing, System.Data.MappingType.Element)

Me.columnBroj_indeksa.ExtendedProperties.Add("Gene rator_ColumnPropNameInRow",
"Broj_indeksa")

Me.columnBroj_indeksa.ExtendedProperties.Add("Gene rator_ColumnPropNameInTable",
"Broj_indeksaColumn")

Me.columnBroj_indeksa.ExtendedProperties.Add("Gene rator_ColumnVarNameInTable",
"columnBroj_indeksa")

Me.columnBroj_indeksa.ExtendedProperties.Add("Gene rator_UserColumnName",
"Broj indeksa")
MyBase.Columns.Add(Me.columnBroj_indeksa)
Me.columnBroj_pohadjanja = New System.Data.DataColumn("Broj
pohadjanja", GetType(Integer), Nothing, System.Data.MappingType.Element)

Me.columnBroj_pohadjanja.ExtendedProperties.Add("G enerator_ColumnPropNameInRow",
"Broj_pohadjanja")

Me.columnBroj_pohadjanja.ExtendedProperties.Add("G enerator_ColumnPropNameInTable",
"Broj_pohadjanjaColumn")

Me.columnBroj_pohadjanja.ExtendedProperties.Add("G enerator_ColumnVarNameInTable",
"columnBroj_pohadjanja")

Me.columnBroj_pohadjanja.ExtendedProperties.Add("G enerator_UserColumnName",
"Broj pohadjanja")
MyBase.Columns.Add(Me.columnBroj_pohadjanja)
Me.Constraints.Add(New
System.Data.UniqueConstraint("Constraint1", New System.Data.DataColumn()
{Me.columnBroj_iksice}, true))
Me.columnBroj_iksice.AllowDBNull = false
Me.columnBroj_iksice.Unique = true
Me.columnPrezime.MaxLength = 255
Me.columnIme.MaxLength = 255
Me.columnBroj_indeksa.MaxLength = 255
End Sub

I get an error when I add new column with this code:

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Dim noviStupac As Data.DataColumn = New Data.DataColumn("Test
Marko", System.Type.GetType("System.Int32"), Nothing,
System.Data.MappingType.Element)
noviStupac.AutoIncrement = False
noviStupac.DefaultValue = 0

Try

Form2.Studenti1Data.Tables.Item(Index(ComboBox1.Te xt)).Columns.Add(noviStupac)
'Dodaje stupac u tablicu
Form2.Studenti1Data.Tables.Item(Index(ComboBox1.Te xt)).AcceptChanges()

Form2.Table1DataGridView.AutoGenerateColumns = True 'Kada dodas
stupac da se prikaze u prozoru
Novo(Form2.Studenti1Data.Tables.Item(Index(ComboBo x1.Text)).TableName,
"Fill") 'Ponovo prikazuje tablicu u datom prozoru

Catch ex As Exception

MsgBox("Vec postoji dati stupac!", MsgBoxStyle.Exclamation,
"Upozorenje!")

End Try
End Sub

The error is:
System.Data.OleDb.OleDbException was unhandled
ErrorCode=-2147217887
Message="Cannot update 'TEST Marko'; field not updateable."
Source="Microsoft JET Database Engine"
StackTrace:
at
System.Data.Common.DbDataAdapter.UpdatedRowStatusE rrors(RowUpdatedEventArgs
rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at
System.Data.Common.DbDataAdapter.UpdatedRowStatus( RowUpdatedEventArgs
rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows,
DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.UpdateFromDataTab le(DataTable
dataTable, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataTable dataTable)
at Diplomski1.Form1.Novo(String nova1, String nova2) in
D:\OdMomka\Diplomski\Diplomski1\Diplomski1\Form1.v b:line 305
at Diplomski1.Form2.Table1BindingNavigatorSaveItem_Cl ick(Object
sender, EventArgs e) in
D:\OdMomka\Diplomski\Diplomski1\Diplomski1\Form2.v b:line 8
at System.Windows.Forms.ToolStripItem.RaiseEvent(Obje ct key,
EventArgs e)
at System.Windows.Forms.ToolStripButton.OnClick(Event Args e)
at System.Windows.Forms.ToolStripItem.HandleClick(Eve ntArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(M ouseEventArgs
e)
at System.Windows.Forms.ToolStripItem.FireEventIntera ctive(EventArgs
e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(Event Args e,
ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEven tArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message&
m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG&
msg)
at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32
reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationCo ntext context)
at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.Run(String[]
commandLine)
at Diplomski1.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAss embly()
at
System.Runtime.Hosting.ApplicationActivator.Create Instance(ActivationContext
activationContext, String[] activationCustomData)
at
System.Runtime.Hosting.ApplicationActivator.Create Instance(ActivationContext
activationContext)
at
Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssemblyDebugInZone()
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

I didn't set autoincrement as true.
I dont know wat is wrong!
Can you help me...!


Jan 24 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.