/// <summary> /// Initializes a new instance of the <see cref="CUBRIDCommand" /> class. /// </summary> public CUBRIDCommand() { paramCollection = new CUBRIDParameterCollection(); isPrepared = false; cmdType = CommandType.Text; cmdText = String.Empty; stmtType = StmtType.NORMAL; }
/// <summary> /// Initializes a new instance of the <see cref="CUBRIDCommand" /> class. /// </summary> public CUBRIDCommand() { paramCollection = new CUBRIDParameterCollection(); isPrepared = false; cmdType = CommandType.Text; cmdText = String.Empty; stmtType = StmtType.NORMAL; }
/// <summary> /// Test CUBRIDParameterCollection class /// </summary> private static void Test_Parameters_Collection() { string errMsg; using (CUBRIDConnection conn = new CUBRIDConnection()) { conn.ConnectionString = TestCases.connString; conn.Open(); CUBRIDParameterCollection pcoll = new CUBRIDParameterCollection(); CUBRIDParameter p1 = new CUBRIDParameter("?p1", CUBRIDDataType.CCI_U_TYPE_INT); p1.Value = 1; pcoll.Add(p1); CUBRIDParameter p2 = new CUBRIDParameter("?p2", CUBRIDDataType.CCI_U_TYPE_CHAR); p2.Value = 'A'; pcoll.Add(p2); CUBRIDParameter p3 = new CUBRIDParameter("?p3", CUBRIDDataType.CCI_U_TYPE_NULL); p3.Value = null; pcoll.Add(p3); //Try to add again p1 errMsg = ""; try { pcoll.Add(p1); throw new Exception(); } catch (Exception ex) { errMsg = ex.Message; } Debug.Assert(errMsg == "Parameter already added to the collection!"); Debug.Assert(pcoll.Count == 3); Debug.Assert(pcoll["?p1"].ParameterName == "?p1"); Debug.Assert(pcoll[1].ParameterName == "?p2"); Debug.Assert(pcoll["?p1"].DbType == DbType.Int32); Debug.Assert(pcoll[1].DbType == DbType.StringFixedLength); Debug.Assert(pcoll[2].DbType == DbType.Object); Debug.Assert((int)pcoll[0].Value == 1); Debug.Assert((char)pcoll[1].Value == 'A'); Debug.Assert(pcoll[2].Value == null); //Try get non-existing parameter errMsg = ""; try { string str = pcoll["?p11"].ParameterName; } catch (Exception ex) { errMsg = ex.Message; } Debug.Assert(errMsg == "?p11: Parameter not found in the collection!"); //Try get non-existing parameter errMsg = ""; try { string str = pcoll[99].ParameterName; } catch (Exception ex) { errMsg = ex.Message; } Debug.Assert(errMsg == "Index was outside the bounds of the array."); pcoll.RemoveAt(1); pcoll.Remove(p1); Debug.Assert(pcoll.Count == 1); pcoll.Clear(); Debug.Assert(pcoll.Count == 0); } }