Forum » Programiranje » [c#] Cudna napaka pri vpisu vrstice (row) v bazo
[c#] Cudna napaka pri vpisu vrstice (row) v bazo
KernelPanic ::
Spostovani!
Spet bi rabil pomoc, in sicer pri sledeci kodi:
1) Ce tabelo izpraznim na serverju, se izvede stavek
2) Ce tabela ze vsebuje record, se izvede stavek
Spet bi rabil pomoc, in sicer pri sledeci kodi:
void saveParametersToDatabase() { System.Console.WriteLine("Entering saveParametersToDatabase()"); // test code DataRow drStatusTargetRow; float fNumber = 0; bool bOk = false; int iNumberOfRows = this.m_datasetPinus.ACCULOAD_STATUS.Count; UInt32 iValue = 0; if (iNumberOfRows > 0) { // table is not empty, access 0-th record, alter it and save it back to db table drStatusTargetRow = this.m_datasetPinus.ACCULOAD_STATUS.Rows[0]; } else { // table is empty, add a record drStatusTargetRow = this.m_datasetPinus.ACCULOAD_STATUS.NewRow(); } // if // **** TRANSFER VALUES TO RECORD drStatusTargetRow[AccuLoadIIIMonitor.TableStatus.FieldNames. FIELD_SLAVE_ADDRESS] = this.m_aiAcculoadIIISlaveAddresses[0]; bOk = this.m_CoreFunctions[0].readFlowRateAverage(ref fNumber); if (!bOk) fNumber = 0; drStatusTargetRow[AccuLoadIIIMonitor.TableStatus.FieldNames. FIELD_FLOW_RATE_AVERAGE] = fNumber; bOk = this.m_CoreFunctions[0].readTemperature(ref fNumber); if (!bOk) fNumber = 0; drStatusTargetRow[AccuLoadIIIMonitor.TableStatus.FieldNames. FIELD_TEMPERATURE] = fNumber; bOk = this.m_CoreFunctions[0].readPresetVolume(ref iValue); if (!bOk) fNumber = 0; drStatusTargetRow[AccuLoadIIIMonitor.TableStatus.FieldNames. FIELD_PRESET] = iValue; drStatusTargetRow[AccuLoadIIIMonitor.TableStatus.FieldNames. FIELD_ARM_PARKED] = this.m_ssDigitalIO5.m_bState; drStatusTargetRow[AccuLoadIIIMonitor.TableStatus.FieldNames. FIELD_GROUNDING] = this.m_ssDigitalIO7.m_bState; drStatusTargetRow[AccuLoadIIIMonitor.TableStatus.FieldNames. FIELD_OVERFILL] = this.m_ssDigitalIO1.m_bState; drStatusTargetRow[AccuLoadIIIMonitor.TableStatus.FieldNames. FIELD_CONDITIONS_PLC] = this.m_ssDigitalIO9.m_bState; drStatusTargetRow[AccuLoadIIIMonitor.TableStatus.FieldNames. FIELD_ESD] = this.m_ssDigitalIO4.m_bState; drStatusTargetRow[AccuLoadIIIMonitor.TableStatus.FieldNames. FIELD_ALARM_PRESENT] = this.m_bwParams.m_bAlarmCondition; drStatusTargetRow[AccuLoadIIIMonitor.TableStatus.FieldNames. FIELD_PRODUCT_FLOWING] = this.m_ssProductFlowing.m_bState; drStatusTargetRow[AccuLoadIIIMonitor.TableStatus.FieldNames. FIELD_TIMESTAMP] = DateTime.Now; // saves timestamp // **** END OF TRANSFER VALUES TO RECORD if (iNumberOfRows > 0) { // table is not empty, save changed in SAME row int iRowsAffected = this.m_taStatus.Update(this.m_datasetPinus); } else { // table empty, save now row this.m_datasetPinus.ACCULOAD_STATUS.Rows.Add(drStatusTargetRow); } this.m_datasetPinus.ACCULOAD_STATUS.AcceptChanges(); System.Console.WriteLine("Exiting saveParametersToDatabase()"); // test code } // saveParametersToDatabase()Namrec, naloga je, da tabela vsebuje le en record (prebrani podatki iz naprave), zato funkcija preveri, ce je tabela prazna, vstavi nov record, ce ni prazna, spremeni 0-ti record in ga nazaj shrani v tabelo. Vendar se zgodi sledece:
1) Ce tabelo izpraznim na serverju, se izvede stavek
// table empty, save now row this.m_datasetPinus.ACCULOAD_STATUS.Rows.Add(drStatusTargetRow);in nato AcceptChanges(), kar je ok, vendar zapisa ni v tabeli.
2) Ce tabela ze vsebuje record, se izvede stavek
// table is not empty, save changed in SAME row int iRowsAffected = this.m_taStatus.Update(this.m_datasetPinus);in nato spet AcceptChanges(), vendar tu v konzoli pride do sledece napake:
A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dllMi lahko kdo pomaga prosim???
A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Step into: Stepping over method without symbols 'System.ComponentModel.BackgroundWorker.WorkerThreadStart'
Step into: Stepping over method without symbols 'System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage'
Step into: Stepping over method without symbols 'System.Threading.ThreadPoolWorkQueue.Dispatch'
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | [c#] Vprasanje glede eventovOddelek: Programiranje | 1416 (1130) | Looooooka |
» | c# - mssql kombinacija / problem pri zapisu row-a v bazoOddelek: Programiranje | 1623 (1432) | darkolord |
» | [c#] Vprasanje glede BackGroundWorker classa in spreminanja gui elementaOddelek: Programiranje | 798 (724) | Ericssony |
» | [c#] Vprašanje glede release verzije aplikacijeOddelek: Programiranje | 1516 (1340) | Ericssony |
» | Tezava pri instanciranju class-aOddelek: Programiranje | 1316 (1187) | KernelPanic |