Created
October 29, 2010 21:27
-
-
Save ebruning/654460 to your computer and use it in GitHub Desktop.
Populate a SQL database with a bunch of rows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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