Alex Gordon
Alex Gordon

Reputation: 60691

update table with c# and mysql

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

Answers (4)

Jimmy W
Jimmy W

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

Steven Dorfmeister
Steven Dorfmeister

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

Matthew Flaschen
Matthew Flaschen

Reputation: 284786

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

Upvotes: 1

Related Questions