You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using(varduckDBConnection=newDuckDBConnection("Data Source=file.db")){duckDBConnection.Open();usingvarcommand=duckDBConnection.CreateCommand();command.CommandText="CREATE TABLE integers(foo INTEGER, bar INTEGER);";varexecuteNonQuery=command.ExecuteNonQuery();command.CommandText="INSERT INTO integers VALUES (3, 4), (5, 6), (7, 8);";executeNonQuery=command.ExecuteNonQuery();command.CommandText="Select count(*) from integers";varexecuteScalar=command.ExecuteScalar();command.CommandText="SELECT foo, bar FROM integers";varreader=command.ExecuteReader();PrintQueryResults(reader);}privatestaticvoidPrintQueryResults(DbDataReaderqueryResult){for(varindex=0;index<queryResult.FieldCount;index++){varcolumn=queryResult.GetName(index);Console.Write($"{column} ");}Console.WriteLine();while(queryResult.Read()){for(intordinal=0;ordinal<queryResult.FieldCount;ordinal++){varval=queryResult.GetInt32(ordinal);Console.Write(val);Console.Write(" ");}Console.WriteLine();}}
Known Issues
When debugging your project that uses DuckDB.NET library, you may get the following error: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. The error happens due to debugger interaction with the native memory. For a workaround check out Debugger Options mess up debugging session during Marshalling