Solved

Updating SQ Server record using C#

Posted on 2013-12-03
1
210 Views
Last Modified: 2013-12-10
I am a newbie to C#,  
My requirement is to manually update a record with data from FormView (VS 2005).

I have the following method where I am getting the value from the fields on the Form.
I am loading them into DtInventory class .  I would like to update the table Inventory with the class values where PartNumberID = the class PartNumberID value.

See the method below:


 protected void Fv_Update(object sender, EventArgs e)
        {

            DtInventory i = new DtInventory();
            i.PartNumberId = Convert.ToInt32(GetValue("PartNumberIDTextBox", ref FormView1));
            i.PartNumber = GetValue("PartNumberTextBox", ref FormView1);
            i.ILSNumber = GetValue("ILSNumberTextBox", ref FormView1);
            i.Revision = GetValue("RevisionTextBox", ref FormView1);
            i.Revision = GetValue("RevisionTextBox", ref FormView1);
            i.Quantity = Convert.ToInt32(GetValue("QuantityTextBox", ref FormView1));
            i.Description = GetValue("DescriptionTextBox", ref FormView1);
            i.MtlDueDate = Convert.ToDateTime(GetValue("MtlDueDateTextBox", ref FormView1));
            i.SerialNumber = GetValue("SerialNumberTextBox", ref FormView1);
            i.MtlReceiptDate = Convert.ToDateTime(GetValue("MtlReceiptDateTextBox", ref FormView1));
            i.PurchaseOrder = GetValue("PurchaseOrderTextBox", ref FormView1);
            i.Supplier = GetValue("SupplieTextBox", ref FormView1);
            i.Location = GetValue("LocationTextBox", ref FormView1);            
            i.Comments = GetValue("CommentsTextBox", ref FormView1);

           string connectionSring = System.Configuration.ConfigurationManager.ConnectionStrings

           ["TrackSparesRepairsConnectionString"].ConnectionString;

          // HOW DO I update table Inventory with the DtInventory class values where
         //  PartNUmberID = i.PartNumberID
        }
0
Comment
Question by:cookiejar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
ItWorked earned 500 total points
ID: 39694639
If you are working with ADO.NET then you can have Dataset ( which is collection of DataTable and allows TWO way communication back-forward with DB which DataTable does not provide)

or you can have a method which saves/updates your Entity into Database. (Assuming you aren't using EF or Linq)

else EF has functionality to do so directly by your DatabaseContext.SaveChange() method.
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question