473,395 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Error updating new column...!

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
1 1465
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: R Baumann | last post by:
I'm a newbie with Python, and trying to connect to the Interbase/Firebird 'EMPLOYEE.GDB' file to play with it. Can anyone help with this? I'm running Firebird 1.5rc4 Python 2.3.2 kinterbasdb...
8
by: Sean Shanny | last post by:
To all, The facts: PostgreSQL 7.4.0 running on BSD 5.1 on Dell 2650 with 4GB RAM, 5 SCSI drives in hardware RAID 0 configuration. Database size with indexes is currently 122GB. DB size...
1
by: Luis Esteban Valencia | last post by:
Hello Everyone, Iam an intermediate ASP.Net programmer and iam facing a challenging task. I have a table in MS-SQL server database called 'Members'. The table has following fields... ...
0
by: cwbp17 | last post by:
I'm having trouble updating individual datagrid cells. Have two tables car_master (columns include Car_ID, YEAR,VEHICLE) and car_detail (columns include Car_ID,PRICE,MILEAGE,and BODY);both tables...
0
by: Steve Amey | last post by:
Hi all I am having a problem when I am updating my database. I am using a strong DS and the PK column is an Identity column, but when I am udating my database I am getting the exception 'Column...
0
by: shil | last post by:
Hi all, updating SQL database with the data.I'm stuck with an issue. One of the XML file from the list don't have a node mentioned. For example almost all XML files structure is like this ...
1
by: shil | last post by:
Hi all, updating SQL database with the data.I'm stuck with an issue. One of the XML file from the list don't have a node mentioned. For example almost all XML files structure is like this ...
33
by: bill | last post by:
In an application I am writing the user can define a series of steps to be followed. I save them in a sql database using the field "order" (a smallint) as the primary key. (there are in the range...
9
by: Marianne160 | last post by:
Hi, I know there are various answers to this problem available on the web but none of them seem to work for me. I am using Access 2003 to make a form to look up data from a table. I have so far...
0
by: mbenedict | last post by:
I am rather new at this code and am attempting to modify existing code to use clob datatypes, which I have never used before. The database tables have been set up for clob data. When trying to use...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.