Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created September 28, 2017 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NMZivkovic/b511f672f0a43b99bfd92bf0f6f3184d to your computer and use it in GitHub Desktop.
Save NMZivkovic/b511f672f0a43b99bfd92bf0f6f3184d to your computer and use it in GitHub Desktop.
using (var sqlConnection = new SqlConnection(connectionString))
{
sqlConnection.Open();
try
{
using (var readCommand = new SqlCommand("select * from Entity", sqlConnection))
{
var reader = readCommand.ExecuteReader();
while (reader.Read())
{
currenValue = reader.GetInt32(0);
type = reader.GetInt32(1);
}
reader.Close();
}
using (var updateCommand = new SqlCommand(String.Format("update Entity set Data = {0} where Data = {1}", newValue, currenValue), sqlConnection))
{
updateCommand.ExecuteNonQuery();
}
Console.WriteLine("Data successfuly modified!");
Console.ReadLine();
}
catch(Exception e)
{
Console.WriteLine("Failed to modify data");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment