HeavenCore
Well-known member
hi, quick sql question really
just doing a simple insert in ado:
the ID of this table is an 'identity specification yes-1,1' and thus auto-increments, when i do an insert is there an efficient way of reading back the generated ID?
I thought of doing a pre-emptive query ie max(id) + 1 and inserting this ID, but this table is being accessed by multiple people and this is not exactly sensible, any ideas?
just doing a simple insert in ado:
VB.NET:
Dim SQLstatement2 As New SqlClient.SqlCommand("Insert Into tblEnclosureTasks (TaskStartTime,TaskEndTime,TaskType_fk) VALUES (@StartTime,@EndTime,@Type)", theDatabase)
SQLstatement2.Parameters.AddWithValue("StartTime", DateTimePicker1.Value)
SQLstatement2.Parameters.AddWithValue("EndTime", DateTimePicker2.Value)
SQLstatement2.Parameters.AddWithValue("Type", lblNewTaskType.Text)
QueryResults = SQLstatement2.ExecuteReader()
the ID of this table is an 'identity specification yes-1,1' and thus auto-increments, when i do an insert is there an efficient way of reading back the generated ID?
I thought of doing a pre-emptive query ie max(id) + 1 and inserting this ID, but this table is being accessed by multiple people and this is not exactly sensible, any ideas?