Gray_code_element

Thursday, April 9, 2020

Insert a new record into the SQL table using Insert Into

This example inserts an integer (PersonID, a varchar (LastName), and float (LargeNumber) variable.

Note that for the SQL, it is a float which is 8 bytes, which corresponds to a double in .Net, see https://stackoverflow.com/questions/1056323/difference-between-numeric-float-and-decimal-in-sql-server




SqlCommand command = new SqlCommand("INSERT INTO dbo.FRANK (PersonID,LastName,LargeNumber) VALUES (@id,@lastname,@number)",cnn);
double BigNumber = 1234.564;
command.Parameters.AddWithValue("@id", 1);
command.Parameters.AddWithValue("@lastname", "John Hufnagel");
command.Parameters.AddWithValue("@number", BigNumber);
int result = command.ExecuteNonQuery();
Console.WriteLine("I think it is done");
// Check Error
if (result < 0)
  Console.WriteLine("Error inserting data into Database!");
                

Establishing connection to SQL Server on local machine, C#

The machine name is JOHN-PC
The SQL Server name is: TEW_SQLEXPRESS
The database name is myDB


using System;
using System.Data.SqlClient;

namespace CSharpConnectToSQLServer
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            string connetionString = null;
            SqlConnection cnn;
            connetionString = @"Server = JOHN-PC\TEW_SQLEXPRESS; Database=myDB; Trusted_Connection=Yes;";
            cnn = new SqlConnection(connetionString);
            try
            {
                cnn.Open();
                Console.WriteLine("Connection Open ! ");
                cnn.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Can not open connection ! ");
            }
            Console.ReadLine();

        }
    }
}

Thanks to: https://www.connectionstrings.com/sql-server/
Using the @ symbol: https://stackoverflow.com/questions/22311799/c-sharp-connection-string-error
The general body of the code: https://stackoverflow.com/questions/22803975/connection-to-sql-server-express-from-c-sharp

Connecting to a SQL Server from Visual Studio

https://blogs.gre.ac.uk/cmssupport/application-development/programming/asp-net/connecting-to-sql-server-using-visual-studio/

Setting up SQL Server Express with SQL Server Management Studio


https://youtu.be/DI1cXYtlQlo

SQL Server Management Studio located at https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver15

MS Access opening a DAO database recordset

https://docs.microsoft.com/en-us/office/client-developer/access/desktop-database-reference/database-openrecordset-method-dao

Wednesday, April 8, 2020

Private vs Public Equity

I was reading in the Globe and Mail about Micheal Lee-Chin going back into the investment fund business by focusing on private equity.

Private equity is where private individuals (or corporations) invest in a company. This is contrast to public equity where anyone with access to the stock market can invest in a company. All companies start off life as private equity: A person may start a business in their own garage or studio, funding the company out of their own savings or convincing a few friends or investors, or maybe even convincing the dudes on Lion's Den, to fund their company. In any event, it is individual people that are coming forward and putting the money in the company.

As company grow, they often want to get access to a larger pool of capital so the have an IPO (initial public offering). After Facebook's latest experience, IPO should be a common household term. Now in Facebook's case, they did not go public because they wanted access to more capital. They are growing at quite a nice rate and their revenues and investments seem to enable Facebook to go where it wants. Rather, Facebook was regulated to go public because it had too many investors

Find out what wakes my computer from sleep:

At the command prompt, type:

powercfg -lastwake

Enable Administrator Account in Windows 7

Search cmd.exe in start menu and run cmd.exe as administrator.

To enable Administrator account Type: net user administrator /active:yes

Thanks to: https://www.instructables.com/id/3-Ways-to-Enable-Administrator-Account-in-Windows-/

y bar

y + hold Alt, type 0773