I'm using Visual Studio 2010 PostgreSQL 9.x Npgsql
I'm trying to insert data from fields on a C# WinForms app. I just can't figure out how to generate/retrieve the next primary key value on the fly. Here are my column names:
epiphanyKey [PK] bigserial transaction numeric license character dateOfActv date time time
I need the insert command to be "session-safe" since multiple people could be entering data into the database at the same time.
NpgsqlConnection conn = new NpgsqlConnection("Server=localhost;Port=5432;User Id=postgres;Password=password;Database=epiphany;"); // postgres 8.3 on my test system
conn.Open(); // opens the connection
NpgsqlCommand cmd = new NpgsqlCommand("INSERT INTO wsmsmrs210 (epiphanyKey,transaction,license,dateOfActv,time, conn);
NpgsqlDataReader dr = cmd.ExecuteReader();
In the code above the NpgsqlCommand cmd = ... statement doesn't work correctly because I don't know the next primary key value for the primary key value epiphanyKey.
Any ideas or code sniplets to generate the next primary key value when sending the query to the db?