Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Where's the row?
Message
De
05/03/2003 16:41:46
 
 
À
05/03/2003 16:36:04
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
00749976
Message ID:
00761804
Vues:
29
Roland,

Hmmm ... lemme see if I remember what we were talking about, it was so long ago ... <g>

The code I posted with ds.Tables[0] is C# (it would be ds.Tables(0) I think in VB) ... anyway, yes, it's the table with index 0. If the table Listings is the first (or only) table in your DataSet, then ds.Tables(0) would be the same as ds.Tables("Listings").

~~Bonnie


>Hi Bonnie,
>
>I have been busy trying to get my app running.
>Thanks for your help!!!!
>
>However I do not understand the ds.Tables[0] part of the code line. Does that mean table index 0 and if so what would be the actual table name?
>
>Something like:
>
>   DataRow row = ds.Tables("Listings").NewRow()
>
>
>Or do you have to use:
>
>
>   DataRow row = ds.Tables(0).NewRow()
>
>
>Thanks
>Roalnd
>
>===========================================================================
>>Roland,
>>
>>This statement gets a new row with the same structure as you're already using:
>>
>>  DataRow row = ds.Tables[0].NewRow()
>>
>>This statement adds that row to your DataSet:
>>
>>  ds.Tables[0].Rows.Add(row)
>>
>>This statement sets your BindingContext position to the new row you just added (note that Cathi corrected my original post, which I knew but had had a brain fart <g> ... it should have been .Count - 1):
>>
>>  BindingContext(ds, "Listing").Position = ds.Tables[0].Rows.Count - 1
>>
>>
>>~~Bonnie
>>
>>
>>
>>
>>>Hi Bonnie,
>>>
>>>How does the new row get added to the end of the real dataset; table?
>>>
>>>I do not understand the following line. Where does it get the position?
>>>
>>>
>>>BindingContext(ds, "Listing").Position = ds.Tables[0].Rows.Count
>>>
>>>
>>>Thanks
>>>Roland
>>>==========================================================================
>>>>Roland,
>>>>
>>>>I think it's been mentioned here before that it's better to add a row with the Table's NewRow() method than with the BindingContext's AddNew() method. So, you'd do something like this (remember, I use C#, so my VB syntax may be slightly off):
>>>>
>>>>
>>>>  DataRow row = ds.Tables[0].NewRow()
>>>>  ds.Tables[0].Rows.Add(row)
>>>>  BindingContext(ds, "Listing").Position = ds.Tables[0].Rows.Count
>>>>
>>>>
>>>>~~Bonnie
>>>>
>>>>
>>>>>Hi,
>>>>>
>>>>>When the following code is executed I get an error message:
>>>>>
>>>>>There is no row at position.
>>>>>
>>>>> 'Add a New Record
>>>>> Me.Pending01_DS1.Listing.Clear()
>>>>> Me.BindingContext(Pending01_DS1, "Listing").AddNew()
>>>>>
>>>>> ' Defaults for New Listing in Table
>>>>> Dim iAddCurrRow As Integer
>>>>> iAddCurrRow = Me.BindingContext.Pending01_DS1, "Listing").Position
>>>>> Me.Pending01_DS1.Tables("Listing").Rows(iAddCurrRow).Item("DateInsert") = Now
>>>>>
>>>>>Where is the row I just added with AddNew command?
>>>>>
>>>>>What do I need to do to correct this error?
>>>>>
>>>>>Thanks
>>>>>Roland
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform