Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time
using System;
using System.Data;
using System.Data.SqlClient;
using TechTalk.SpecFlow;
using TechTalk.SpecFlow.Assist;
namespace TestExample
public interface ISqlHelper
void InsertPersons(Table table);
public class SqlHelper : ISqlHelper
private string connectionString;
public SqlHelper(string connectionString)
this.connectionString = connectionString;
public void InsertPersons(Table table)
using (SqlConnection conn = new SqlConnection(connectionString))
var deleteCommand = new SqlCommand("DELETE FROM dbo.person", conn);
SqlCommand insertCommand = new SqlCommand(@"
INSERT INTO dbo.person
(name, age)
VALUES (@name, @age)", conn);
insertCommand.Parameters.Add("@name", SqlDbType.VarChar);
insertCommand.Parameters.Add("@age", SqlDbType.Int);
var rows = table.CreateSet<Person>();
foreach (Person row in rows)
insertCommand.Parameters["@name"].Value = row.Name;
insertCommand.Parameters["@age"].Value = row.Age;
class Person
public string Name { get; set; }
public int Age { get; set; }