我有这个代码:
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();
}
当我插入这个表时,我有一个名为 Osnovni_br 的 auto_increment int 主键列。如何在 MessageBox 或 MessageBox 中获取该列 (Osnovni_br) 的最后一个值?