public void InsertRow(string myConnectionString)
{
// If the connection string is empty, use default.
if(myConnectionString == "")
{
myConnectionString =
"User Id=sa;Server=localhost;Initial Catalog=Test;";
}
SqlConnection myConn = new SqlConnection(myConnectionString);
string myInsertQuery = "INSERT INTO DEPT VALUES (50,'Development','Philadelphia')";
SqlCommand myCommand = new SqlCommand(myInsertQuery);
myCommand.Connection = myConn;
myConn.Open();
try
{
myCommand.ExecuteNonQuery();
}
finally
{
myConn.Close();
}
}