@Andomar
my application uploads a file on server and save it to db and bind it to (gridview with remove link for each row)
if i use last_value iam getting the same last id evry time
SqlConnection connection = new SqlConnection(ConfigurationManager.AppSettings["DSN"]);
SqlCommand ident = new SqlCommand("select LAST_VALUE where name = 'Id' and object_id = object_id('image')", connection);
connection.Open();
id = Convert.ToInt32(ident.ExecuteScalar());
_fileName = fileName;
_fullFileName = _outputPath + (id + 1).ToString() + prefix + Path.GetFileName(_fileName);
_fs = new FileStream(_fullFileName, FileMode.Create);
:
:
:
my problem is that wen i was using MAX(Id) like below ,it was all fine until i loose my identity when someone deletes the last row or MAX row ....that is why i am trying to get the last autoincremented identity not the last value of id coloumn
SqlConnection connection = new SqlConnection(ConfigurationManager.AppSettings["DSN"]);
SqlCommand ident = new SqlCommand("SELECT MAX(Id) from image", connection);
connection.Open();
SqlDataReader result = ident.ExecuteReader();
result.Read();
object obValue = result.GetValue(0);
id = Convert.ToInt32(obValue.ToString());
connection.Close();