linq to sql update
-
This statment works but I want to get the value of whatever the user inputted. I do not want a new row in sql, I just want to modifiy companyName. //Create new instance AlternaDB.MarketingDataContext db = new AlternaDB.MarketingDataContext(); //Call the table you want to use AlternaDB.Distributor distributor = db.Distributors.Single(d => d.CompanyName == "Nike"); AlternaDB.Distributor tbl = new AlternaDB.Distributor(); distributor.CompanyName = "krb"; db.SubmitChanges(); ShowDistributors(); CREATE TABLE [dbo].[Distributor]( [DistributorID] [int] IDENTITY(1,1) NOT NULL, [AccountType] [int] NULL, [AccountStatus] [int] NULL, [CompanyName] [varchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, )
-
This statment works but I want to get the value of whatever the user inputted. I do not want a new row in sql, I just want to modifiy companyName. //Create new instance AlternaDB.MarketingDataContext db = new AlternaDB.MarketingDataContext(); //Call the table you want to use AlternaDB.Distributor distributor = db.Distributors.Single(d => d.CompanyName == "Nike"); AlternaDB.Distributor tbl = new AlternaDB.Distributor(); distributor.CompanyName = "krb"; db.SubmitChanges(); ShowDistributors(); CREATE TABLE [dbo].[Distributor]( [DistributorID] [int] IDENTITY(1,1) NOT NULL, [AccountType] [int] NULL, [AccountStatus] [int] NULL, [CompanyName] [varchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, )
Member 1416254 wrote:
This statment works but I want to get the value of whatever the user inputted
This statement combined with your code sample makes no sense I'm afraid.. In order to perform the update your code would have to know both the old and the new the company name to begin with, thus nothing new to discover. Try re-phrasing your question so we can understand :wtf: