By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,780 Members | 1,550 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,780 IT Pros & Developers. It's quick & easy.

Help with updating & modify data

P: n/a
Hi everyone,

I have posted earlier this week, but I'm still scratching my head trying to
figure out how to change/modify my data back to my db.

Using C# Windows forms. I am trying to learn how to modify existing data
with in my DB/MSDE. In general, I have textbox's filled with existing data
from my "Employee" table. I have amongst other buttons, an "Update" button.
Where, when viewing, if I want to change ie the persons name, anyother
field, or all fields I want to press the update button. However I am getting
lost. My code is below with the 3 fields I want to update. Mapping is in the
correct order. Hopefully someone can help by providing correct code or a
link example.

private void btnEmpModify_Click(object sender, System.EventArgs e)
{
DataTable thisTable = dsModifyRecord.Tables["Employee"];
//THIS IS WHERE I'M GETTING LOST
thisTable.Rows[??????????????];

thisRow["EmpFName"] = txtBoxEmpFName.Text;
thisRow["EmpLName"] = txtBoxLNName.Text;
thisRow["EmpTitle"] = txtBoxEmpTitle.Text;
//& GETTING LOST HERE
dsModifyRecord.Tables["EMPLOYEE"]??????????????
sqlDataAdapter1.Update(dsModifyRecord, "Employee");
}

Thank you all in advance

MikeY
Nov 15 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi Mike,

DataTable can contain many rows, you have to select the one that you want to
update.
When you read your data froom the database, it returns several records, one
record, or no records.
How do you fill the text box with your data? Which record from your
DataTable are you using?
co**************@yahoo.com

"MikeY" <mi*******@yahoo.ca> wrote in message
news:uV**************@TK2MSFTNGP12.phx.gbl...
Hi everyone,

I have posted earlier this week, but I'm still scratching my head trying to figure out how to change/modify my data back to my db.

Using C# Windows forms. I am trying to learn how to modify existing data
with in my DB/MSDE. In general, I have textbox's filled with existing data
from my "Employee" table. I have amongst other buttons, an "Update" button. Where, when viewing, if I want to change ie the persons name, anyother
field, or all fields I want to press the update button. However I am getting lost. My code is below with the 3 fields I want to update. Mapping is in the correct order. Hopefully someone can help by providing correct code or a
link example.

private void btnEmpModify_Click(object sender, System.EventArgs e)
{
DataTable thisTable = dsModifyRecord.Tables["Employee"];
//THIS IS WHERE I'M GETTING LOST
thisTable.Rows[??????????????];

thisRow["EmpFName"] = txtBoxEmpFName.Text;
thisRow["EmpLName"] = txtBoxLNName.Text;
thisRow["EmpTitle"] = txtBoxEmpTitle.Text;
//& GETTING LOST HERE
dsModifyRecord.Tables["EMPLOYEE"]??????????????
sqlDataAdapter1.Update(dsModifyRecord, "Employee");
}

Thank you all in advance

MikeY

Nov 15 '05 #2

P: n/a
Hi Mike,

DataTable can contain many rows, you have to select the one that you want to
update.
When you read your data froom the database, it returns several records, one
record, or no records.
How do you fill the text box with your data? Which record from your
DataTable are you using?
co**************@yahoo.com

"MikeY" <mi*******@yahoo.ca> wrote in message
news:uV**************@TK2MSFTNGP12.phx.gbl...
Hi everyone,

I have posted earlier this week, but I'm still scratching my head trying to figure out how to change/modify my data back to my db.

Using C# Windows forms. I am trying to learn how to modify existing data
with in my DB/MSDE. In general, I have textbox's filled with existing data
from my "Employee" table. I have amongst other buttons, an "Update" button. Where, when viewing, if I want to change ie the persons name, anyother
field, or all fields I want to press the update button. However I am getting lost. My code is below with the 3 fields I want to update. Mapping is in the correct order. Hopefully someone can help by providing correct code or a
link example.

private void btnEmpModify_Click(object sender, System.EventArgs e)
{
DataTable thisTable = dsModifyRecord.Tables["Employee"];
//THIS IS WHERE I'M GETTING LOST
thisTable.Rows[??????????????];

thisRow["EmpFName"] = txtBoxEmpFName.Text;
thisRow["EmpLName"] = txtBoxLNName.Text;
thisRow["EmpTitle"] = txtBoxEmpTitle.Text;
//& GETTING LOST HERE
dsModifyRecord.Tables["EMPLOYEE"]??????????????
sqlDataAdapter1.Update(dsModifyRecord, "Employee");
}

Thank you all in advance

MikeY

Nov 15 '05 #3

P: n/a
Hi Codewriter,

I fill my textbox's with a sql datareader. What I do is a search for a
particular field. If the field is found, I output the info to textbox's but
I wanted to have the ability to mdofiy, ie persons first name if needed. A
sample of my code is as follows for the datareader/search:
try
{
string userinput = txtBoxEmpSearch.Text;
sqlConnection1.Open();
string select = "SELECT * FROM Employee WHERE (EmpID = '" + userinput +
"')";
SqlCommand cmd = new SqlCommand(select, sqlConnection1);
SqlDataReader myReader = cmd.ExecuteReader();
while(myReader.Read())
{
returnedValue = myReader.GetString(1);
userIDOutPut = Convert.ToString(myReader.GetInt32(0));
userFNameOutPut = myReader.GetString(1);
userLNameOutPut = myReader.GetString(2);
userTitleOutPut = myReader.GetString(3);
txtBoxtmp.Text = myReader.GetString(3); //Temp for Deletion
}

Thanks for help.
"codewriter" <co**************@yahoo.com> wrote in message
news:VE********************@news20.bellglobal.com. ..
Hi Mike,

DataTable can contain many rows, you have to select the one that you want to update.
When you read your data froom the database, it returns several records, one record, or no records.
How do you fill the text box with your data? Which record from your
DataTable are you using?
co**************@yahoo.com

"MikeY" <mi*******@yahoo.ca> wrote in message
news:uV**************@TK2MSFTNGP12.phx.gbl...
Hi everyone,

I have posted earlier this week, but I'm still scratching my head trying

to
figure out how to change/modify my data back to my db.

Using C# Windows forms. I am trying to learn how to modify existing data
with in my DB/MSDE. In general, I have textbox's filled with existing data from my "Employee" table. I have amongst other buttons, an "Update"

button.
Where, when viewing, if I want to change ie the persons name, anyother
field, or all fields I want to press the update button. However I am

getting
lost. My code is below with the 3 fields I want to update. Mapping is in

the
correct order. Hopefully someone can help by providing correct code or a
link example.

private void btnEmpModify_Click(object sender, System.EventArgs e)
{
DataTable thisTable = dsModifyRecord.Tables["Employee"];
//THIS IS WHERE I'M GETTING LOST
thisTable.Rows[??????????????];

thisRow["EmpFName"] = txtBoxEmpFName.Text;
thisRow["EmpLName"] = txtBoxLNName.Text;
thisRow["EmpTitle"] = txtBoxEmpTitle.Text;
//& GETTING LOST HERE
dsModifyRecord.Tables["EMPLOYEE"]??????????????
sqlDataAdapter1.Update(dsModifyRecord, "Employee");
}

Thank you all in advance

MikeY


Nov 15 '05 #4

P: n/a
Hi Codewriter,

I fill my textbox's with a sql datareader. What I do is a search for a
particular field. If the field is found, I output the info to textbox's but
I wanted to have the ability to mdofiy, ie persons first name if needed. A
sample of my code is as follows for the datareader/search:
try
{
string userinput = txtBoxEmpSearch.Text;
sqlConnection1.Open();
string select = "SELECT * FROM Employee WHERE (EmpID = '" + userinput +
"')";
SqlCommand cmd = new SqlCommand(select, sqlConnection1);
SqlDataReader myReader = cmd.ExecuteReader();
while(myReader.Read())
{
returnedValue = myReader.GetString(1);
userIDOutPut = Convert.ToString(myReader.GetInt32(0));
userFNameOutPut = myReader.GetString(1);
userLNameOutPut = myReader.GetString(2);
userTitleOutPut = myReader.GetString(3);
txtBoxtmp.Text = myReader.GetString(3); //Temp for Deletion
}

Thanks for help.
"codewriter" <co**************@yahoo.com> wrote in message
news:VE********************@news20.bellglobal.com. ..
Hi Mike,

DataTable can contain many rows, you have to select the one that you want to update.
When you read your data froom the database, it returns several records, one record, or no records.
How do you fill the text box with your data? Which record from your
DataTable are you using?
co**************@yahoo.com

"MikeY" <mi*******@yahoo.ca> wrote in message
news:uV**************@TK2MSFTNGP12.phx.gbl...
Hi everyone,

I have posted earlier this week, but I'm still scratching my head trying

to
figure out how to change/modify my data back to my db.

Using C# Windows forms. I am trying to learn how to modify existing data
with in my DB/MSDE. In general, I have textbox's filled with existing data from my "Employee" table. I have amongst other buttons, an "Update"

button.
Where, when viewing, if I want to change ie the persons name, anyother
field, or all fields I want to press the update button. However I am

getting
lost. My code is below with the 3 fields I want to update. Mapping is in

the
correct order. Hopefully someone can help by providing correct code or a
link example.

private void btnEmpModify_Click(object sender, System.EventArgs e)
{
DataTable thisTable = dsModifyRecord.Tables["Employee"];
//THIS IS WHERE I'M GETTING LOST
thisTable.Rows[??????????????];

thisRow["EmpFName"] = txtBoxEmpFName.Text;
thisRow["EmpLName"] = txtBoxLNName.Text;
thisRow["EmpTitle"] = txtBoxEmpTitle.Text;
//& GETTING LOST HERE
dsModifyRecord.Tables["EMPLOYEE"]??????????????
sqlDataAdapter1.Update(dsModifyRecord, "Employee");
}

Thank you all in advance

MikeY


Nov 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.