[ wex-alpha @ 09.08.2011. 11:37 ] @
Zadatak je, pronaci istu string vrijednost u bazi(barcode), te uraditi update int(stanje) polja. Baza je Uploaded with ImageShack.us metoda koja to radi je: Code: public void AzurirajKolicinu(string barcode, int kolicina) { SqlCeConnection con = new SqlCeConnection(@"Data Source = |DataDirectory|\intercom.sdf"); con.Open(); SqlCeCommand com = new SqlCeCommand("update prodaja set stanje =" + kolicina.ToString() + " WHERE barcode= " + barcode, con); com.Parameters.AddWithValue("@stanje", kolicina); com.ExecuteNonQuery(); con.Close(); Znaci nadji barkod iz baze, i azuriraj njegovo int kolicina polje sa novom vrijednoscu. Ovo radi ako imam barkodove koji su >= 14 karaktera (primjer: 1234567890123). Ovo ne radi ako imam barkodove koji su <= od 13 karaktera (123456789012) Greska koju dobijem je: exception.message Code: --------------------------- --------------------------- Expression evaluation caused an overflow. [ Name of function (if known) = ] --------------------------- OK --------------------------- Malo detaljnije: MessageBox.Show(a.InnerException + "\n" + a.Source + "\n" + a.StackTrace + "\n" + a.TargetSite); Code: SQL Server Compact ADO.NET Data Provider at System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr) at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommandText(IntPtr& pCursor, Boolean& isBaseTableCursor) at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, resultSetOptions options) at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery() at POSkasa.konekcija.AzurirajKolicinu(String barcode, Int32 kolicina) in C: Cini mi se da negdje dolazi do kolizije tipa podataka, ali gdje? |