Practical Information Flashcards
1
Q
How do you start a transaction?
A
SqlTransaction transaction = connection.BeginTransaction();
2
Q
How do you create SQL command Objecs when dealing with transactions?
A
SqlCommand command = connection.CreateCommand() ; command.Transaction = transaction;
3
Q
What control block must be used with transactions?
A
try and cactch block
4
Q
How do you use parametized queries?
A
string query = "SELECT * FROM products WHERE Name = @Name"; SqlCommand command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@Name", userInput);
5
Q
How do you see if a reader object has rows?
A
reader.HasRows