public string BindValues(CommandParams cmdParams, bool forPrepareStmt) { StringBuilder strBuilder = new StringBuilder(); int count = _sqlSections.Count; for (int i = 0; i < count; i++) { var sqlSection = _sqlSections[i]; switch (sqlSection.sectionKind) { default: throw new NotSupportedException(); case SqlSectionKind.SqlText: strBuilder.Append(sqlSection.Text); break; case SqlSectionKind.ValueKey: if (forPrepareStmt) { strBuilder.Append('?'); } else { //get bind data MyStructData bindedData; if (!cmdParams.TryGetData(sqlSection.Text, out bindedData)) { throw new Exception("Error : This key not assign." + sqlSection.Text); } else { //format data FormatAndAppendData(strBuilder, ref bindedData); } } break; case SqlSectionKind.SpecialKey: string found; if (cmdParams.TryGetSqlPart(sqlSection.Text, out found)) { strBuilder.Append(found); } else { throw new Exception("not found " + sqlSection.Text); } break; } } return(strBuilder.ToString()); }
public MyStructData[] PrepareBoundData(CommandParams cmdParams) { //1. check proper type and //2. check all values are in its range //extract and arrange int j = _keys.Count; for (int i = 0; i < j; ++i) { SqlBoundSection key = _keys[i]; if (!cmdParams.TryGetData(key.Text, out _preparedValues[i])) { //not found key throw new Exception("not found " + _keys[i].Text); } else { //------------------------------- //TODO: check here //all field type is 253 ? //error //------------------------------- //check //FieldPacket fieldInfo = key.fieldInfo; //switch ((MySqlDataType)fieldInfo.columnType) //{ // case MySqlDataType.VARCHAR: // case MySqlDataType.VAR_STRING: // { // //check length // if (_preparedValues[i].myString.Length > fieldInfo.maxLengthOfField) // { // //TODO: notify user how to handle this data // //before error // } // } // break; // case MySqlDataType.BLOB: // case MySqlDataType.LONG_BLOB: // case MySqlDataType.MEDIUM_BLOB: // { // if (_preparedValues[i].myString.Length > fieldInfo.maxLengthOfField) // { // //TODO: notify user how to handle this data // //before error // } // } // break; //} } } return(_preparedValues); }
public MyStructData[] PrepareBoundData(CommandParams cmdParams) { //1. check proper type and //2. check all values are in its range //extract and arrange int j = _keys.Count; for (int i = 0; i < j; ++i) { SqlBoundSection key = _keys[i]; if (!cmdParams.TryGetData(key.Text, out _preparedValues[i])) { //not found key throw new Exception("not found " + _keys[i].Text); } else { //------------------------------- //TODO: check here //all field type is 253 ? //error //------------------------------- //check //FieldPacket fieldInfo = key.fieldInfo; //switch ((MySqlDataType)fieldInfo.columnType) //{ // case MySqlDataType.VARCHAR: // case MySqlDataType.VAR_STRING: // { // //check length // if (_preparedValues[i].myString.Length > fieldInfo.maxLengthOfField) // { // //TODO: notify user how to handle this data // //before error // } // } // break; // case MySqlDataType.BLOB: // case MySqlDataType.LONG_BLOB: // case MySqlDataType.MEDIUM_BLOB: // { // if (_preparedValues[i].myString.Length > fieldInfo.maxLengthOfField) // { // //TODO: notify user how to handle this data // //before error // } // } // break; //} } } return _preparedValues; }