I have this code:
private void btnPotvrdi_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=BCKPSRVR;Initial Catalog=protokol;Integrated Security=True");
con.Open();
SqlCommand sc = new SqlCommand("insert into Knjiga (Datum_prijema, Predmet, Posiljalac, Adresa_posiljaoca, Primaoc, Datum_proslijeda) values ('" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "','" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + dateTimePicker2.Value.ToString("yyyy-MM-dd") + "');", con);
int o=sc.ExecuteNonQuery();
MessageBox.Show(o + " :Podaci su unešeni");
con.Close();
}
When I insert into this table, I have an auto_increment int primary key column called Osnovni_br. How can i get the last value of that column (Osnovni_br) in MessageBox or insted of MessageBox?