how to input data as id in database sql c 23

Solutions on MaxInterview for how to input data as id in database sql c 23 by the best coders in the world

showing results for - "how to input data as id in database sql c 23"
Rafael
17 Sep 2019
1    using(SqlCommand cmd=new SqlCommand("INSERT INTO Mem_Basic(Mem_Na,Mem_Occ) output INSERTED.ID VALUES(@na,@occ)",con))
2    {
3        cmd.Parameters.AddWithValue("@na", Mem_NA);
4        cmd.Parameters.AddWithValue("@occ", Mem_Occ);
5        con.Open();
6
7        int modified =(int)cmd.ExecuteScalar();
8
9        if (con.State == System.Data.ConnectionState.Open) 
10            con.Close();
11
12        return modified;
13    }
14}
15