1

i apologize in advance for the elementary questions

i am using:

command.CommandText = "select * from some_table;"

to retrieve data

can i do use the same thing to update data?

4 Answers 4

1

I assume that command is an instance of SqlCommand. In which case, yes you can. Here is a code fragment detailing what you should do to update data:

command.Connection = (Insert connection string here);
command.CommandText = (Insert update statement);
int numRowsUpdated = command.ExecuteNonQuery();

As I type three answers came in. No need to apologize; we're happy to help!

Sign up to request clarification or add additional context in comments.

Comments

1

Here are some simple examples on reading and writing to a database.

Comments

1

There's a lot of ways, but one is to use a SQL update statement and parameterized statements.

Comments

1

The above examples are great ones, you could also look at LINQ.

http://msdn.microsoft.com/en-us/library/bb399398.aspx

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.