Solved

Updating SQ Server record using C#

Posted on 2013-12-03
1
202 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
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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now