Click here to Skip to main content
15,911,715 members
Home / Discussions / C#
   

C#

 
GeneralRe: Update() database from DataSet Pin
PIEBALDconsult5-May-07 3:59
mvePIEBALDconsult5-May-07 3:59 
GeneralRe: Update() database from DataSet Pin
Dave Kreskowiak5-May-07 18:04
mveDave Kreskowiak5-May-07 18:04 
GeneralRe: Update() database from DataSet Pin
aecordoba2-May-07 12:57
aecordoba2-May-07 12:57 
AnswerRe: Update() database from DataSet Pin
PIEBALDconsult2-May-07 11:14
mvePIEBALDconsult2-May-07 11:14 
GeneralRe: Update() database from DataSet Pin
aecordoba2-May-07 13:00
aecordoba2-May-07 13:00 
GeneralRe: Update() database from DataSet Pin
PIEBALDconsult2-May-07 13:32
mvePIEBALDconsult2-May-07 13:32 
GeneralRe: Update() database from DataSet Pin
aecordoba3-May-07 5:57
aecordoba3-May-07 5:57 
AnswerRe: Update() database from DataSet Pin
DarthDub2-May-07 17:43
DarthDub2-May-07 17:43 
First off do you have your update command made yet?

I'll I know how to do with DataAdapters is the sql part of them, but if thats what your doing here is an example. It should be kinda the same type of thing.

<cod>
SqlConnection CNN = new SqlConnection("Data Source=(local);Initial Catalog=Northwind;Integrated Security=true");
SqlDataAdapter DA = new SqlDataAdapter();
DataSet DS = new DataSet();

SqlCommand cmdSelect = CNN.CreateCommand();
cmdSelect.CommandText = "Select CustomerID, ContactName, CompanyName From Customers";

// create an Update command
SqlCommand cmdUpdate = CNN.CreateCommand();
cmdUpdate.CommandText = "Update Customers SET CompanyName=@CompanyName, ContactName=@ContactName WHERE CustomerID=@CustomerID";
cmdUpdate.Parameters.Add("@CompanyName",
SqlDbType.NVarChar, 40, "CompanyName");
cmdUpdate.Parameters.Add("@ContactName",
SqlDbType.NVarChar, 30, "ContactName");
cmdUpdate.Parameters.Add("@CustomerID",
SqlDbType.NChar, 5, "CustomerID");
cmdUpdate.Parameters["@CustomerID"].SourceVersion =
DataRowVersion.Original;

// create an Insert command
SqlCommand cmdInsert = CNN.CreateCommand();
cmdInsert.CommandText =
"Insert into customers (customerid, companyname, contactname) Values (@customerid, @companyname, @contactname)";
cmdInsert.Parameters.Add("@customerid",
SqlDbType.NChar, 5, "customerid");
cmdInsert.Parameters.Add("@companyname",
SqlDbType.NVarChar, 40, "companyname");
cmdInsert.Parameters.Add("@contactname",
SqlDbType.NVarChar, 30, "contactname");
cmdInsert.Parameters["@customerid"].SourceVersion =
DataRowVersion.Original;

// create a Delete command
SqlCommand cmdDelete = CNN.CreateCommand();
cmdDelete.CommandText = "Delete from customers Where customerid = @customerid";
cmdDelete.Parameters.Add("@customerid",
SqlDbType.NChar, 5, "customerid");
cmdDelete.Parameters["@customerid"].SourceVersion =
DataRowVersion.Original;

DA.SelectCommand = cmdSelect;
DA.UpdateCommand = cmdUpdate;
DA.InsertCommand = cmdInsert;
DA.DeleteCommand = cmdDelete;
DA.Fill(DS, "Customers");

//then do whatever you want to with modifying it.
//And then just do update like this

DA.Update(DS, "Customers");


Castro

QuestionWeb Services Pin
AnithaArvind2-May-07 10:46
AnithaArvind2-May-07 10:46 
AnswerRe: Web Services Pin
Christian Graus2-May-07 11:20
protectorChristian Graus2-May-07 11:20 
GeneralRe: Web Services Pin
AnithaArvind2-May-07 13:49
AnithaArvind2-May-07 13:49 
GeneralRe: Web Services Pin
Dave Kreskowiak2-May-07 16:15
mveDave Kreskowiak2-May-07 16:15 
QuestionSend print file to printer, C# Pin
T.Willey2-May-07 10:06
T.Willey2-May-07 10:06 
AnswerRe: Send print file to printer, C# Pin
DarthDub2-May-07 18:29
DarthDub2-May-07 18:29 
GeneralRe: Send print file to printer, C# Pin
T.Willey3-May-07 5:10
T.Willey3-May-07 5:10 
QuestionDirectSound Secondary Buffer problem Pin
Andrei Ungureanu2-May-07 9:59
Andrei Ungureanu2-May-07 9:59 
AnswerRe: DirectSound Secondary Buffer problem Pin
Leslie Sanford2-May-07 10:28
Leslie Sanford2-May-07 10:28 
QuestionWeb Service & Directories Pin
royk1232-May-07 9:26
royk1232-May-07 9:26 
AnswerRe: Web Service & Directories Pin
Tarakeshwar Reddy2-May-07 9:37
professionalTarakeshwar Reddy2-May-07 9:37 
GeneralRe: Web Service & Directories Pin
royk1232-May-07 17:27
royk1232-May-07 17:27 
QuestionProject Reference Not Updating Pin
ATCsharp2-May-07 9:13
ATCsharp2-May-07 9:13 
QuestionProgramattically add user or group to folder Pin
Aaron VanWieren2-May-07 8:48
Aaron VanWieren2-May-07 8:48 
QuestionDrawing bits to a window handle Pin
Symbul2-May-07 8:05
Symbul2-May-07 8:05 
AnswerRe: Drawing bits to a window handle Pin
AFSEKI7-May-07 6:12
AFSEKI7-May-07 6:12 
QuestionHow to Pin
Askalo2-May-07 7:54
Askalo2-May-07 7:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.