I have a sql table temp.it has 4 columns, 3 of which are primary keys(composite). While doing a insert to a table I need to check if the composite PK exists already in table. If yes I need to update the row else I need to insert a new row to temp table. Can I proceed this way. I don't know hoe to check for PK in table. Kindly guide me. Below is the Insert
string constr = ConfigurationManager.ConnectionStrings["constr"].ToString();
using (OdbcConnection con = new OdbcConnection(constr))
{
try
{
string query = "Insert into temp_table(Name,DeptName,Alias,City) values(name,dept,alias,city)";
con.Open();
OdbcCommand cmd = new OdbcCommand(query, con);
cmd.ExecuteNonQuery();
}
here name, dept and city are composite primary key.