Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Change Value of a Field
Message
 
 
À
23/07/2009 14:07:49
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:
01414020
Vues:
41
>>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.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform