Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Change Value of a Field
Message
De
02/08/2009 18:00:55
 
 
À
24/07/2009 15:16:45
Joel Whitehead
Ccs Central Computer Services Inc.
Thunder Bay, Ontario, Canada
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Versions des environnements
Environment:
VB 9.0
OS:
Windows XP SP2
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01414003
Message ID:
01415812
Vues:
60
So Joel, I'm curious how you got it working. Which pieces of Naomi's code did you end up using? I was going to suggest altering your DataSet to not use PK, non-null or any other kinds of constraints. But, maybe that's just me. <g>

~~Bonnie



>>>>I know this is how we did it recently, I can check some of my code for this if you want it.
>>>
>>>Yes, I would love to see some code. Now that I have the variable xGuid, I would think just one line of code is needed to reference the cuspk field in the dataset and change the value... its this piece of code and how the reference the field in my dataset programmatically that has me stumped.
>>
>>Here are two samples I found (I was using TA in my code - which I believe is not a very good practice)
>>
>>public Guid InsertCustomer(string Contact, string Company, string Address1, string Address2, string City, string State, string Zip, string Phone, string Email)
>>        {
>>            CustomersTableAdapter ta = new CustomersTableAdapter();
>>            Guid newPK = Guid.NewGuid();
>>            int results = 0;
>>            results = ta.Insert(newPK, Contact, Company, Address1, Address2, City, State, Zip, Phone, Email, DateTime.Now, DateTime.Now);
>>
>>            if (results <= 0)
>>                newPK = Guid.Empty;
>>
>>            return newPK;
>>        }
>>
>>
>>/// <summary>
>>        /// Insert new order      
>>        /// </summary>
>>        /// <param name="dr">data row</param>
>>        /// <returns>ID of new record</returns>
>>        public int InsertNewOrder(OrdersDataSet.OrdersRow dr)
>>        {
>>            int retVal;
>>            using (OrdersTableAdapter ta = new OrdersTableAdapter())
>>            {
>>                dr.OrderPk  = Guid.NewGuid();
>>
>>                retVal = (int)ta.InsertNewOrder(dr.OrderPk, dr.CustomerFK);
>>            }
>>        
>>            return retVal;
>>        }
>>
>>So, it looks like you need to get a reference to the DataRow and then you can access fields of this row and assign them values.
>
>Thanks Naomi! That code helped to point me in the right direction. Got it working this morning!
Bonnie Berent DeWitt
NET/C# MVP since 2003

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

Click here to load this message in the networking platform