-
22-02-2010, 16:53 #1Member
- Registered
- 17/07/02
- Location
- Mechelen
- Posts
- 1,785
- iTrader
- 21 (100%)
- Mentioned
- 0 Post(s)
- Reputation
- 0/4
c# datagridview toont andere id's dan databank bevat
Hallo
Ik ben bezig aan een windows applicatie in visual studio 2008 op windows 7.
Deze applicatie maakt gebruik van een database die draait op een sql server. Maar nu is er een probleem met gegevens van een bepaalde tabel in een gridview te late zien. Maar deze toont verkeerde gegevens. De opdracht_id's worden ipv hun echte waarde getallen van -1 tot -n getoond en en de opdracht_lector_id's helemaal niet.
Heeft iemand enig idee hoe ik dit kan oplossen?
Evert
no votes
-
-
22-02-2010, 22:34 #2Member
- Registered
- 21/10/05
- Location
- Herentals
- Posts
- 1,515
- iTrader
- 5 (100%)
- Mentioned
- 0 Post(s)
- Reputation
- 2/13
Als Opdracht_ID een autonummeringsveld is, is dat normaal. Visual Studio gebruikt standaard -1 als autoincrement en -1 als seed voor zo'n veld net om problemen te vermijden (vooral als je programma door meerdere gebruikers zou gebruikt worden).
(ADO.NET Cookbook)An AutoIncrement column generates a series of values beginning with the AutoIncre
mentSeed value and is incremented by the AutoIncrementStep value with each new value.
This easily allows you to generate unique values for an integer-type column. A potential
problem occurs when new rows are being inserted into an existing table for an identity
field (in SQL Server) where the generated values conflict with existing values in the
table because of, perhaps, new records added to the data source by other users. In this
case, instead of being interpreted as new records by the data source, these records are
incorrectly interpreted as updates of existing records.
The problem can be avoided by setting the AutoIncrementSeed value to -1 and the
AutoIncrementStep value to -1 thereby generating a sequence of negative values that
does not conflict with the values generated by the data source, as long as the data source
does not generate negative values. When the disconnected data is reconciled with the
underlying data (see Recipe 4.2), the data source correctly identifies the records that
have negative AutoIncrement field values as new records, adds them to the data source,
and in the process generates new values for the AutoIncrement field. Recipe 4.2 discusses
synchronizing these data source-generated values with the disconnected data.
Wat het probleem met opdracht_lector_id is, kan ik zo niet zeggen."And we wept, Precious. We wept to be so alone." --- Gollum
"Sometimes there are no words. No clever quotes to neatly sum up what happened that day. Sometimes, the day just . . . ends." --- Hotch (Criminal Minds)no votes
