Reputation: 60691
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?
Upvotes: 1
Views: 549
Reputation: 539
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!
Upvotes: 1
Reputation: 200
The above examples are great ones, you could also look at LINQ.
http://msdn.microsoft.com/en-us/library/bb399398.aspx
Upvotes: 1
Reputation: 284786
There's a lot of ways, but one is to use a SQL update statement and parameterized statements.
Upvotes: 1
Reputation: 9051
Here are some simple examples on reading and writing to a database.
Upvotes: 1