嗨,我正在提交要访问的表单,但希望在我提交后获得访问分配的自动编号以显示在文本框中。下面是我有的,任何建议都会很棒!
string cmdstr = "Insert into TaskPerformed(TaskType,OtherType,Analyst,DateCompleted)Values(@b,@c,@d,@e)";
string query2 = "Select @@IDENTITY";
OleDbConnection con1 = new OleDbConnection(constr);
OleDbCommand com = new OleDbCommand(cmdstr, con1);
OleDbCommand cmdNewID = new OleDbCommand("SELECT @@IDENTITY", con1);//
con1.Open();
cmd.CommandText = query2;
com.ExecuteNonQuery();
con1.Close();
label16.Text = cmdNewID.ToString();