Skip to content

Instantly share code, notes, and snippets.

@ebruning
Created October 29, 2010 21:27
Show Gist options
  • Save ebruning/654460 to your computer and use it in GitHub Desktop.
Save ebruning/654460 to your computer and use it in GitHub Desktop.
Populate a SQL database with a bunch of rows
static void Main(string[] args)
{
string _connectionString = ("server=vrsbase-w2k3;" +
"database=express;" +
"user=sa;" +
"password=");
string _sql = string.Empty;
SqlConnection conn = null;
// 2. Create and open a connection object
conn = new SqlConnection(_connectionString);
// 3. Open the Connection
conn.Open();
for (int x = 1; x <= 50000; x++)
{
_sql =
string.Format(
@"INSERT INTO dbo.airway (number, name) VALUES ('{0}', 'Bobby Lee');", x);
SqlCommand command = new SqlCommand(_sql, conn);
string returnvalue = (string) command.ExecuteScalar();
Console.WriteLine(string.Format("Writting record {0} -> Value ({1})", x, returnvalue));
}
conn.Close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment