Check alle échte Black Friday-deals Ook zo moe van nepaanbiedingen? Wij laten alleen échte deals zien

[C#] Datatable loop gaat fout

Pagina: 1
Acties:

  • bastv
  • Registratie: September 2005
  • Laatst online: 15-11 00:39
Ik ben redelijk nieuw met ASP.NET (ben bezig met de overgang van asp naar .net)

Nu heb ik al heel wat uren lopen zwoegen en zweten en nu loop ik tegen een probleem aan.

Ik heb een Dataset gemaakt met de naam MES.
Ik heb een BLL gemaakt met de namen:
  • InspectedProductPropertiesBll.cs
  • InstructionPropertiesBLL.cs
Het doel van dit script is om een het veld "Location_ID" uit "InstructionProperties" te halen en toe te voegen in "InspectedProductProperties".
Dit omdat het veld Location_ID is toegevoegd aan InspectedProductProperties en een primary key moet worden.

Door instructionProperties uit te lezen kan ik deze variabelen vullen:
C#:
1
2
3
4
5
6
short template_ID;
string instructionCode;
short property_ID;
DateTime startDate;
DateTime expireDate;
short location_ID;


Nu moet ik ook InspectedProductProperties uitlezen voor deze variabele:
C#:
1
int inspectedProduct_ID


Nu alle variabelen aanwezig zijn kan ik InspectedProductProperties updaten met Location_ID uit InstructionProperties.

Dit heb ik tot nu toe gemaakt:
C#:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//BLL API's
InstructionPropertiesBLL instructionPropertiesAPI = new InstructionPropertiesBLL();
InspectedProductPropertiesBLL inspectedProductPropertiesAPI = new InspectedProductPropertiesBLL();

//instructionProperties ophalen
MES.InstructionPropertiesDataTable instructionProperties = instructionPropertiesAPI.GetInstructionProperties();

//progressbar max instellen
pbarInsertInProductProp.Maximum = instructionProperties.Count;

foreach (MES.InstructionPropertiesRow instructionPropertie in instructionProperties)
{
    short template_ID = instructionPropertie.Template_ID;
    string instructionCode = instructionPropertie.InstructionCode;
    short property_ID = instructionPropertie.Property_ID;
    DateTime startDate = instructionPropertie.Startdate;
    DateTime expireDate = instructionPropertie.Expiredate;
    short location_ID = instructionPropertie.Location_ID;

    //InspectedProductproperties laden en locatie vullen

    MES.InspectedProductPropertiesDataTable inspectedProductProperties = inspectedProductPropertiesAPI.GetInspectedProductProperties(property_ID, startDate, expireDate, template_ID, instructionCode);
    foreach (MES.InspectedProductPropertiesRow inspectedProductpropertie in inspectedProductProperties)
    {
        int inspectedProduct_ID = inspectedProductpropertie.InspectedProduct_ID;
        inspectedProductPropertieAPI.UpdateProductPropertie(inspectedProduct_ID, property_ID, location_ID);
    }

    //progressbar updaten
    pbarInsertInProductProp.PerformStep();
}


Alleen gaat deze regel niet goed. (de rest wel, datatables worden gevuld etc.)
C#:
1
inspectedProductPropertieAPI.UpdateProductPropertie(inspectedProduct_ID, property_ID, location_ID);

hij geeft als melding:
"Then name 'inspectedProductPropertieAPI' does not exist in the current context"
de rest gaat wel goed.

Ik kan maar niet vinden wat ik niet goed doe.
En heb ik het wel netjes geprogrammeerd? of moet ik andere functies gebruiken zoals arrays etc?

  • Face_-_LeSS
  • Registratie: September 2004
  • Niet online
Maak er "inspectedProductPropertiesAPI" van...

  • Ansur
  • Registratie: Januari 2004
  • Laatst online: 29-10 13:35
Ik zie 'inspectedProductPropertieAPI' nergens gedeclareerd staan, maar wel een 'inspectedProductPropertiesAPI'. Typo maybe?

  • bastv
  • Registratie: September 2005
  • Laatst online: 15-11 00:39
@#$#^$&%^&#$%

als jullie eens wisten hoeveel uur ik hier mee bezig ben geweest.

is de manier van programmeren wel goed ? dat weet ik ook niet zeker omdat ik hier nieuw mee ben en ook redelijk nieuw met het OOP programmeren.

Thanx!!

  • aaiding
  • Registratie: April 2004
  • Laatst online: 05-11-2020
Gebruik je wel VisualStudio? Die had dit toch tijdens 't compileren gemerkt?

  • Haan
  • Registratie: Februari 2004
  • Laatst online: 12:15

Haan

dotnetter

Met een beetje normale IDE had je dit idd binnen 10 seconden achterhaald ;)

Kater? Eerst water, de rest komt later


  • farlane
  • Registratie: Maart 2000
  • Laatst online: 16-11 18:33
FYI enkelvoud is "property" en het meervoud "properties"

Somniferous whisperings of scarlet fields. Sleep calling me and in my dreams i wander. My reality is abandoned (I traverse afar). Not a care if I never everwake.

Pagina: 1