R
Richard Rivera
I have a method called InsertUpdate which I want to use to handle both
insert's and update's. The GUI has a 2 textboxes: First Name and Last Name.
This is what my InsertUpdate method looks like right now.
InsertUpdate method:
SqlConnection cn = new SqlConnection("Initial Catalog=TEST;Data
Source=Server1;Integrated Security= SSPI");
SqlDataAdapter da = new SqlDataAdapter("SELECT ID, FIRST_NAME, LAST_NAME
FROM TableName",cn);
SqlCommandBuilder thisBuilder = new SqlCommandBuilder(da);
DataSet ds = new DataSet();
da.Fill(ds,"TableName");
DataRow thisRow = ds.Tables["TableName"].NewRow();
thisRow["FIRST_NAME"] = txtFirstName.Text;
thisRow["LAST_NAME"] = txtLastName.Text;
ds.Tables["PLAYERS"].Rows.Add(thisRow);
da.Update(ds, "PLAYERS");
The next time I call the InsertUpdate method I want to update my data. How
do I do this with the code above? It obviously works for an insert but how
do I check if the data is dirty? so I can update my data. Any help would be
appreciated.
Richard
(e-mail address removed)
insert's and update's. The GUI has a 2 textboxes: First Name and Last Name.
This is what my InsertUpdate method looks like right now.
InsertUpdate method:
SqlConnection cn = new SqlConnection("Initial Catalog=TEST;Data
Source=Server1;Integrated Security= SSPI");
SqlDataAdapter da = new SqlDataAdapter("SELECT ID, FIRST_NAME, LAST_NAME
FROM TableName",cn);
SqlCommandBuilder thisBuilder = new SqlCommandBuilder(da);
DataSet ds = new DataSet();
da.Fill(ds,"TableName");
DataRow thisRow = ds.Tables["TableName"].NewRow();
thisRow["FIRST_NAME"] = txtFirstName.Text;
thisRow["LAST_NAME"] = txtLastName.Text;
ds.Tables["PLAYERS"].Rows.Add(thisRow);
da.Update(ds, "PLAYERS");
The next time I call the InsertUpdate method I want to update my data. How
do I do this with the code above? It obviously works for an insert but how
do I check if the data is dirty? so I can update my data. Any help would be
appreciated.
Richard
(e-mail address removed)