My method for doing this is to fire an append query then straight away
get the max ID. So long as you haven't got another transaction in the
same millisecond it should work.
e.g.
//Insert New Records into Table
strsql = "Insert Into tblMyTable (intData) Values (1)";
conn = new SqlConnection(csConnections.strConnMyConnection);
command = new SqlCommand(strsql, conn);
conn.Open();
try
{
command.ExecuteNonQuery();
}
catch
{
return "Failure";
}
finally
{
conn.Close();
}
//Get New ID
int intNewID = 0
strsql = "SELECT max(ID) FROM tblMyTable";
command = new SqlCommand(strsql, conn);
conn.Open();
reader = command.ExecuteReader();
while (reader.Read())
{
intNewID = reader.GetInt32(0);
}
conn.Close();
You can now use intNewID for part of your picture name.
Regards
Jared
na********@yahoo.com wrote:
please any urgent response.
Dear alls; (database relevent quetion)
i want to display the next availible primery key {e.g 1,2,3
(autonumbered) next 4} on the user entry form in "label" control.Thanks