Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting row right after insert returns no result
    primarykey
    data
    text
    <p>I am running unit tests and when I try to insert data in the database and getting it right after, I don't get anything (I have tried with <code>DataAdapter</code> and <code>DataReader</code>).</p> <p>However when I put a 3 seconds sleep (even with 1 second it doesn't work...) between the insert and the select I get the result.</p> <p>In SQL Server Profiler I can see the execution, the insert is well done and is completed about 10 miliseconds before the select begins.</p> <p>I can't find out where this comes </p> <p>The code looks like this : Insert method</p> <pre><code>SqlCommand command = new SqlCommand(sqlTemplate); command.Parameters.Add(Sql4oConstants.Sql4oIdParameterName, SqlDbType.UniqueIdentifier).Value = id; command.Parameters.Add(Sql4oConstants.Sql4oTimestampParamterName, SqlDbType.DateTime).Value = DateTime.Now; command.CommandTimeout = dataSourceDescription.CommandTimeout; DatabaseManager.ExecuteNonQuery(dataSourceDescription.ConnectionString, command); </code></pre> <p>Get method</p> <pre><code>public static void Fill(string connectionString, DataTable table, SqlCommand command) { try { LogStorageWriter.WriteLogEntry(log, EStorageLevelLog.Debug, string.Format("Execute query: {0}", command.CommandText)); using (SqlConnection conn = new SqlConnection(connectionString)) { command.Connection = conn; using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { adapter.Fill(table); } } } catch (InvalidOperationException e) { LogStorageWriter.WriteLogEntry(log, EStorageLevelLog.Error, string.Format("Exception : {0}", e.ToString())); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload