What steps will reproduce the problem?
public void Test_InsensColumn()
{
Console.WriteLine("Test Start.");
Console.WriteLine("Create connection...");
SqliteConnection con = new SqliteConnection();
string dbFilename = @"=SqliteTest3=.db";
string cs = string.Format("Version=3,uri=file:{0}", dbFilename);
Console.WriteLine("Set connection String: {0}", cs);
if (File.Exists(dbFilename))
File.Delete(dbFilename);
con.ConnectionString = cs;
Console.WriteLine("Open database...");
con.Open();
Console.WriteLine("create command...");
IDbCommand cmd = con.CreateCommand();
Console.WriteLine("create table TEST_TABLE...");
cmd.CommandText = "CREATE TABLE TEST_TABLE ( COLA INTEGER, COLB TEXT, COLC DATETIME )";
cmd.ExecuteNonQuery();
Console.WriteLine("insert row 1...");
cmd.CommandText = "INSERT INTO TEST_TABLE ( COLA, COLB, COLC ) VALUES (123,'ABC','2008-12-31 18:19:20' )";
cmd.ExecuteNonQuery();
Console.WriteLine("insert row 2...");
cmd.CommandText = "INSERT INTO TEST_TABLE ( COLA, COLB, COLC ) VALUES (124,'DEF', '2009-11-16 13:35:36' )";
cmd.ExecuteNonQuery();
Console.WriteLine("SELECT data from TEST_TABLE...");
cmd.CommandText = "SELECT RowID, COLA, COLB, COLC FROM TEST_TABLE";
IDataReader reader = cmd.ExecuteReader();
int r = 0;
Console.WriteLine("Read the data...");
while (reader.Read())
{
Console.WriteLine(" Row: {0}", r);
int rowid = reader.GetInt32(reader.GetOrdinal("RowID"));
Console.WriteLine(" RowID: {0}", rowid);
int i = reader.GetInt32(reader.GetOrdinal("COLA"));
Console.WriteLine(" COLA: {0}", i);
string s = reader.GetString(reader.GetOrdinal("COLB"));
Console.WriteLine(" COLB: {0}", s);
DateTime dt = reader.GetDateTime(reader.GetOrdinal("COLC"));
Console.WriteLine(" COLB: {0}", dt.ToString("MM/dd/yyyy HH:mm:ss"));
r++;
}
Console.WriteLine("Close and cleanup...");
con.Close();
con = null;
Console.WriteLine("Test Done.");
}
What is the expected output? What do you see instead?
Expected:
Test1 Start.
Create connection...
Set connection String: Version=3,uri=file:=SqliteTest3=.db
Open database...
create command...
create table TEST_TABLE...
insert row 1...
insert row 2...
SELECT data from TEST_TABLE...
Read the data...
Row: 0
RowID: 1
COLA: 123
COLB: ABC
COLB: 12.31.2008 18:19:20
Row: 1
RowID: 2
COLA: 124
COLB: DEF
COLB: 11.16.2009 13:35:36
Close and cleanup...
Test1 Done.
Press Enter to Continue
Actual:
System.Collections.Generic.KeyNotFoundException was unhandled
Message=Данный ключ отсутствует в словаре.
Source=mscorlib
StackTrace:
в System.ThrowHelper.ThrowKeyNotFoundException()
в System.Collections.Generic.Dictionary`2.get_Item(TKey key)
в Community.CsharpSqlite.SQLiteClient.SqliteDataReader.GetOrdinal(String name) в D:\Prog\C#\csharp-sqlite-hg\Community.CsharpSqlite.SQLiteClient\src\SqliteDataReader.cs:строка 451
в SQLiteClientTests.SQLiteClientTestDriver.Test_InsensColumn() в D:\Prog\C#\csharp-sqlite-hg\Community.CsharpSqlite.SQLiteClient\TestDriver_src\SQLiteClientTestDriver.cs:строка 768
в SQLiteClientTests.SQLiteClientTestDriver.Main(String[] args) в D:\Prog\C#\csharp-sqlite-hg\Community.CsharpSqlite.SQLiteClient\TestDriver_src\SQLiteClientTestDriver.cs:строка 868
в System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
в System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
в Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
в System.Threading.ThreadHelper.ThreadStart_Context(Object state)
в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
в System.Threading.ThreadHelper.ThreadStart()
InnerException:
What version of the product are you using? On what operating system?
latest mercurial
Please provide any additional information below.
In file SqliteDataReader.cs:
In constructor internal SqliteDataReader(SqliteCommand cmd, Sqlite3.Vdbe pVm,
int version)
change
column_names_insens = new Dictionary<String, Object>();
to
column_names_insens = new Dictionary<String, Object>(StringComparer.InvariantCultureIgnoreCase);
In function public override int GetOrdinal(string name)
change
object v = column_names_sens[name] ;
if (v == null)
v = column_names_insens[name] ;
if (v == null)
throw new ArgumentException("Column does not exist.");
to
object v = column_names_sens.ContainsKey(name) ? column_names_sens[name] : null;
if (v == null)
v = column_names_insens.ContainsKey(name) ? column_names_insens[name] : null;
if (v == null)
throw new ArgumentException("Column does not exist.");
Original issue reported on code.google.com by ilya...@gmail.com on 15 Jun 2011 at 6:01
Original issue reported on code.google.com by
ilya...@gmail.com
on 15 Jun 2011 at 6:01