Practical Information Flashcards

1
Q

How do you start a transaction?

A

SqlTransaction transaction = connection.BeginTransaction();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you create SQL command Objecs when dealing with transactions?

A
SqlCommand command = connection.CreateCommand() ;
 command.Transaction = transaction;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What control block must be used with transactions?

A

try and cactch block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you see if a reader object has rows?

A

reader.HasRows

How well did you know this?
1
Not at all
2
3
4
5
Perfectly