Search Results

Search found 49435 results on 1978 pages for 'query string'.

Page 15/1978 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • loading xml into SQL Server 2008 using sqlbulkload component

    - by mohamed
    "Error: Schema: relationship expected on 'headerRecord'." I get the above error while load xml file to SQL Server 2008 using SQLXMLBulkLoad4 Component , the xml file contains Call Detail records, I have generated schema file from xml file using both , Dataset and XSD.exe tool, but the error remains same., if there is another way to imports xml file with multiple tables that have relationship in each file into SQL Server 2008? . Here the xml file: <CallEventDataFile> <headerRecord> <productionDateTime>0912021247482B0300</productionDateTime> <recordingEntity>00</recordingEntity> <extensions/> </headerRecord> <callEventRecords> <mtSMSRecord> <recordType>7</recordType> <serviceCentre>91521230</serviceCentre> <servedIMSI>36570000031728F2</servedIMSI> <servedIMEI>53886000707896F0</servedIMEI> <servedMSISDN>915212454503F2</servedMSISDN> <msClassmark>3319A1</msClassmark> <recordingEntity>915212110100</recordingEntity> <location> <locationAreaCode>0006</locationAreaCode> <cellIdentifier>0C6E</cellIdentifier> </location> <deliveryTime>0912021535412B0300</deliveryTime> <systemType> <gERAN/> </systemType> <basicService> <teleservice>21</teleservice> </basicService> <additionalChgInfo> <chargeIndicator>2</chargeIndicator> </additionalChgInfo> <chargedParty> <calledParty/> </chargedParty> <orgRNCorBSCId>8E1A</orgRNCorBSCId> <orgMSCId>921A</orgMSCId> <globalAreaID>36F70500060C6E</globalAreaID> <subscriberCategory>0A</subscriberCategory> <firstmccmnc>36F705</firstmccmnc> <smsUserDataType>FF</smsUserDataType> <origination>8191F2</origination> <callReference>1605EB2FE1</callReference> </mtSMSRecord> <moSMSRecord> <recordType>6</recordType> <servedIMSI>36570000238707F9</servedIMSI> <servedIMEI>53928320195925F0</servedIMEI> <servedMSISDN>915212159430F2</servedMSISDN> <msClassmark>3319A2</msClassmark> <serviceCentre>91521230</serviceCentre> <recordingEntity>915212110100</recordingEntity> <location> <locationAreaCode>001B</locationAreaCode> <cellIdentifier>6983</cellIdentifier> </location> <messageReference>01</messageReference> <originationTime>0912021535412B0300</originationTime> <destinationNumber>8111F1</destinationNumber> <systemType> <gERAN/> </systemType> <basicService> <teleservice>22</teleservice> </basicService> <additionalChgInfo> <chargeIndicator>2</chargeIndicator> </additionalChgInfo> <chargedParty> <callingParty/> </chargedParty> <orgRNCorBSCId>8F1A</orgRNCorBSCId> <orgMSCId>921A</orgMSCId> <globalAreaID>36F705001B6983</globalAreaID> <subscriberCategory>0A</subscriberCategory> <firstmccmnc>36F705</firstmccmnc> <smsUserDataType>FF</smsUserDataType> <callReference>1701BED4FF</callReference> </moSMSRecord> <ssActionRecord> <recordType>10</recordType> <servedIMSI>36570000636448F8</servedIMSI> <servedIMEI>53246030714961F0</servedIMEI> <servedMSISDN>915212056928F8</servedMSISDN> <msClassmark>3018A1</msClassmark> <recordingEntity>915212110100</recordingEntity> <location> <locationAreaCode>000C</locationAreaCode> <cellIdentifier>05A5</cellIdentifier> </location> <supplService>FF</supplService> <ssAction> <ussdInvocation/> </ssAction> <ssActionTime>0912021535412B0300</ssActionTime> <ssParameters> <unstructuredData>AA5C2E3702</unstructuredData> </ssParameters> <callReference>1701BED500</callReference> <systemType> <gERAN/> </systemType> <ussdCodingScheme>0F</ussdCodingScheme> <ussdString> <UssdString>AA5C2E3702</UssdString> </ussdString> <ussdRequestCounter>1</ussdRequestCounter> <additionalChgInfo> <chargeIndicator>1</chargeIndicator> </additionalChgInfo> <orgRNCorBSCId>8E1A</orgRNCorBSCId> <orgMSCId>921A</orgMSCId> <globalAreaID>36F705000C05A5</globalAreaID> <subscriberCategory>0A</subscriberCategory> <firstmccmnc>36F705</firstmccmnc> </ssActionRecord> <moCallRecord> <recordType>0</recordType> <servedIMSI>36570000807501F5</servedIMSI> <servedIMEI>53246030713955F0</servedIMEI> <servedMSISDN>915212157901F0</servedMSISDN> <callingNumber>A151911700</callingNumber> <calledNumber>8151677589</calledNumber> <roamingNumber>A111113850</roamingNumber> <recordingEntity>915212110100</recordingEntity> <mscIncomingROUTE> <rOUTEName>HWBSC2</rOUTEName> </mscIncomingROUTE> <mscOutgoingROUTE> <rOUTEName>HWBSC2</rOUTEName> </mscOutgoingROUTE> <location> <locationAreaCode>0006</locationAreaCode> <cellIdentifier>0C2F</cellIdentifier> </location> <basicService> <teleservice>11</teleservice> </basicService> <msClassmark>3319A1</msClassmark> <answerTime>0912021535382B0300</answerTime> <releaseTime>0912021535422B0300</releaseTime> <callDuration>4</callDuration> <radioChanRequested> <dualFullRatePreferred/> </radioChanRequested> <radioChanUsed> <halfRate/> </radioChanUsed> <causeForTerm>0</causeForTerm> <diagnostics> <gsm0408Cause>144</gsm0408Cause> </diagnostics> <callReference>1701BED501</callReference> <additionalChgInfo> <chargeIndicator>2</chargeIndicator> </additionalChgInfo> <gsm-SCFAddress>915212110130</gsm-SCFAddress> <serviceKey>1</serviceKey> <networkCallReference>171D555132</networkCallReference> <mSCAddress>915212110100</mSCAddress> <speechVersionSupported>25</speechVersionSupported> <speechVersionUsed>21</speechVersionUsed> <numberOfDPEncountered>3</numberOfDPEncountered> <levelOfCAMELService>01</levelOfCAMELService> <freeFormatData>800130</freeFormatData> <systemType> <gERAN/> </systemType> <classmark3>C000</classmark3> <chargedParty> <callingParty/> </chargedParty> <mscOutgoingCircuit>1051</mscOutgoingCircuit> <orgRNCorBSCId>8E1A</orgRNCorBSCId> <orgMSCId>921A</orgMSCId> <calledIMSI>36570000635618F8</calledIMSI> <globalAreaID>36F70500060C2F</globalAreaID> <subscriberCategory>0A</subscriberCategory> <firstmccmnc>36F705</firstmccmnc> <lastmccmnc>36F705</lastmccmnc> </moCallRecord> <mtCallRecord> <recordType>1</recordType> <servedIMSI>36570000635618F8</servedIMSI> <servedIMEI>53464010474309F0</servedIMEI> <servedMSISDN>915212755697F8</servedMSISDN> <callingNumber>A151911700</callingNumber> <recordingEntity>915212110100</recordingEntity> <mscIncomingROUTE> <rOUTEName>HWBSC2</rOUTEName> </mscIncomingROUTE> <mscOutgoingROUTE> <rOUTEName>HWBSC2</rOUTEName> </mscOutgoingROUTE> <location> <locationAreaCode>0006</locationAreaCode> <cellIdentifier>0C2D</cellIdentifier> </location> <basicService> <teleservice>11</teleservice> </basicService> <supplServicesUsed> <SuppServiceUsedid> <ssCode>11</ssCode> <ssTime>0912021535382B0300</ssTime> </SuppServiceUsedid> </supplServicesUsed> <msClassmark>331981</msClassmark> <answerTime>0912021535382B0300</answerTime> <releaseTime>0912021535422B0300</releaseTime> <callDuration>4</callDuration> <radioChanRequested> <dualFullRatePreferred/> </radioChanRequested> <radioChanUsed> <halfRate/> </radioChanUsed> <causeForTerm>0</causeForTerm> <diagnostics> <gsm0408Cause>144</gsm0408Cause> </diagnostics> <callReference>1701BED502</callReference> <additionalChgInfo> <chargeIndicator>2</chargeIndicator> </additionalChgInfo> <networkCallReference>171D555132</networkCallReference> <mSCAddress>915212110100</mSCAddress> <speechVersionSupported>25</speechVersionSupported> <speechVersionUsed>21</speechVersionUsed> <systemType> <gERAN/> </systemType> <classmark3>C000</classmark3> <chargedParty> <calledParty/> </chargedParty> <roamingNumber>A111113850</roamingNumber> <mscIncomingCircuit>9119</mscIncomingCircuit> <orgRNCorBSCId>8E1A</orgRNCorBSCId> <orgMSCId>921A</orgMSCId> <globalAreaID>36F70500060C2D</globalAreaID> <subscriberCategory>0A</subscriberCategory> <firstmccmnc>36F705</firstmccmnc> <lastmccmnc>36F705</lastmccmnc> </mtCallRecord> <incGatewayRecord> <recordType>3</recordType> <callingNumber>A17005991565</callingNumber> <calledNumber>A1853643F7</calledNumber> <recordingEntity>915212110100</recordingEntity> <mscIncomingROUTE> <rOUTEName>ZPSTN</rOUTEName> </mscIncomingROUTE> <mscOutgoingROUTE> <rOUTEName>ZTEBSC3</rOUTEName> </mscOutgoingROUTE> <answerTime>0912021535302B0300</answerTime> <releaseTime>0912021535422B0300</releaseTime> <callDuration>12</callDuration> <causeForTerm>0</causeForTerm> <diagnostics> <gsm0408Cause>144</gsm0408Cause> </diagnostics> <callReference>2203AFBF84</callReference> <basicService> <teleservice>11</teleservice> </basicService> <additionalChgInfo> <chargeIndicator>2</chargeIndicator> </additionalChgInfo> <roamingNumber>A111111980</roamingNumber> <mscIncomingCircuit>934</mscIncomingCircuit> <orgMSCId>921A</orgMSCId> <mscIncomingRouteAttribute> <isup/> </mscIncomingRouteAttribute> <networkCallReference>22432B5132</networkCallReference> </incGatewayRecord> <outGatewayRecord> <recordType>4</recordType> <callingNumber>A151012431</callingNumber> <calledNumber>817026936873</calledNumber> <recordingEntity>915212110100</recordingEntity> <mscIncomingROUTE> <rOUTEName>HWBSC</rOUTEName> </mscIncomingROUTE> <mscOutgoingROUTE> <rOUTEName>ZPSTN</rOUTEName> </mscOutgoingROUTE> <answerTime>0912021535192B0300</answerTime> <releaseTime>0912021535432B0300</releaseTime> <callDuration>24</callDuration> <causeForTerm>0</causeForTerm> <diagnostics> <gsm0408Cause>144</gsm0408Cause> </diagnostics> <callReference>2303B19880</callReference> <basicService> <teleservice>11</teleservice> </basicService> <additionalChgInfo> <chargeIndicator>2</chargeIndicator> </additionalChgInfo> <mscOutgoingCircuit>398</mscOutgoingCircuit> <orgMSCId>921A</orgMSCId> <mscOutgoingRouteAttribute> <isup/> </mscOutgoingRouteAttribute> <networkCallReference>238BE55132</networkCallReference> </outGatewayRecord> </callEventRecords> <trailerRecord> <productionDateTime>0912021247512B0300</productionDateTime> <recordingEntity>00</recordingEntity> <firstCallDateTime>000000000000000000</firstCallDateTime> <lastCallDateTime>000000000000000000</lastCallDateTime> <noOfRecords>521</noOfRecords> <extensions/> </trailerRecord> <extensions/> </CallEventDataFile> Schema File generated by Dataset: <?xml version="1.0" standalone="yes"?> <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xs:element name="location"> <xs:complexType> <xs:sequence> <xs:element name="locationAreaCode" type="xs:string" minOccurs="0" /> <xs:element name="cellIdentifier" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="systemType"> <xs:complexType> <xs:sequence> <xs:element name="gERAN" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="basicService"> <xs:complexType> <xs:sequence> <xs:element name="teleservice" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="additionalChgInfo"> <xs:complexType> <xs:sequence> <xs:element name="chargeIndicator" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="chargedParty"> <xs:complexType> <xs:sequence> <xs:element name="calledParty" type="xs:string" minOccurs="0" /> <xs:element name="callingParty" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="mscIncomingROUTE"> <xs:complexType> <xs:sequence> <xs:element name="rOUTEName" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="mscOutgoingROUTE"> <xs:complexType> <xs:sequence> <xs:element name="rOUTEName" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="radioChanRequested"> <xs:complexType> <xs:sequence> <xs:element name="dualFullRatePreferred" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="radioChanUsed"> <xs:complexType> <xs:sequence> <xs:element name="halfRate" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="diagnostics"> <xs:complexType> <xs:sequence> <xs:element name="gsm0408Cause" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="CallEventDataFile"> <xs:complexType> <xs:sequence> <xs:element name="extensions" type="xs:string" minOccurs="0" /> <xs:element name="headerRecord" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="productionDateTime" type="xs:string" minOccurs="0" /> <xs:element name="recordingEntity" type="xs:string" minOccurs="0" /> <xs:element name="extensions" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="callEventRecords" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="mtSMSRecord" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="recordType" type="xs:string" minOccurs="0" /> <xs:element name="serviceCentre" type="xs:string" minOccurs="0" /> <xs:element name="servedIMSI" type="xs:string" minOccurs="0" /> <xs:element name="servedIMEI" type="xs:string" minOccurs="0" /> <xs:element name="servedMSISDN" type="xs:string" minOccurs="0" /> <xs:element name="msClassmark" type="xs:string" minOccurs="0" /> <xs:element name="recordingEntity" type="xs:string" minOccurs="0" /> <xs:element name="deliveryTime" type="xs:string" minOccurs="0" /> <xs:element name="orgRNCorBSCId" type="xs:string" minOccurs="0" /> <xs:element name="orgMSCId" type="xs:string" minOccurs="0" /> <xs:element name="globalAreaID" type="xs:string" minOccurs="0" /> <xs:element name="subscriberCategory" type="xs:string" minOccurs="0" /> <xs:element name="firstmccmnc" type="xs:string" minOccurs="0" /> <xs:element name="smsUserDataType" type="xs:string" minOccurs="0" /> <xs:element name="origination" type="xs:string" minOccurs="0" /> <xs:element name="callReference" type="xs:string" minOccurs="0" /> <xs:element ref="location" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="systemType" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="basicService" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="additionalChgInfo" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="chargedParty" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="moSMSRecord" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="recordType" type="xs:string" minOccurs="0" /> <xs:element name="servedIMSI" type="xs:string" minOccurs="0" /> <xs:element name="servedIMEI" type="xs:string" minOccurs="0" /> <xs:element name="servedMSISDN" type="xs:string" minOccurs="0" /> <xs:element name="msClassmark" type="xs:string" minOccurs="0" /> <xs:element name="serviceCentre" type="xs:string" minOccurs="0" /> <xs:element name="recordingEntity" type="xs:string" minOccurs="0" /> <xs:element name="messageReference" type="xs:string" minOccurs="0" /> <xs:element name="originationTime" type="xs:string" minOccurs="0" /> <xs:element name="destinationNumber" type="xs:string" minOccurs="0" /> <xs:element name="orgRNCorBSCId" type="xs:string" minOccurs="0" /> <xs:element name="orgMSCId" type="xs:string" minOccurs="0" /> <xs:element name="globalAreaID" type="xs:string" minOccurs="0" /> <xs:element name="subscriberCategory" type="xs:string" minOccurs="0" /> <xs:element name="firstmccmnc" type="xs:string" minOccurs="0" /> <xs:element name="smsUserDataType" type="xs:string" minOccurs="0" /> <xs:element name="callReference" type="xs:string" minOccurs="0" /> <xs:element ref="location" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="systemType" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="basicService" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="additionalChgInfo" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="chargedParty" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="ssActionRecord" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="recordType" type="xs:string" minOccurs="0" /> <xs:element name="servedIMSI" type="xs:string" minOccurs="0" /> <xs:element name="servedIMEI" type="xs:string" minOccurs="0" /> <xs:element name="servedMSISDN" type="xs:string" minOccurs="0" /> <xs:element name="msClassmark" type="xs:string" minOccurs="0" /> <xs:element name="recordingEntity" type="xs:string" minOccurs="0" /> <xs:element name="supplService" type="xs:string" minOccurs="0" /> <xs:element name="ssActionTime" type="xs:string" minOccurs="0" /> <xs:element name="callReference" type="xs:string" minOccurs="0" /> <xs:element name="ussdCodingScheme" type="xs:string" minOccurs="0" /> <xs:element name="ussdRequestCounter" type="xs:string" minOccurs="0" /> <xs:element name="orgRNCorBSCId" type="xs:string" minOccurs="0" /> <xs:element name="orgMSCId" type="xs:string" minOccurs="0" /> <xs:element name="globalAreaID" type="xs:string" minOccurs="0" /> <xs:element name="subscriberCategory" type="xs:string" minOccurs="0" /> <xs:element name="firstmccmnc" type="xs:string" minOccurs="0" /> <xs:element ref="location" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="ssAction" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="ussdInvocation" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="ssParameters" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="unstructuredData" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element ref="systemType" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="ussdString" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="UssdString" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element ref="additionalChgInfo" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="moCallRecord" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="recordType" type="xs:string" minOccurs="0" /> <xs:element name="servedIMSI" type="xs:string" minOccurs="0" /> <xs:element name="servedIMEI" type="xs:string" minOccurs="0" /> <xs:element name="servedMSISDN" type="xs:string" minOccurs="0" /> <xs:element name="callingNumber" type="xs:string" minOccurs="0" /> <xs:element name="calledNumber" type="xs:string" minOccurs="0" /> <xs:element name="roamingNumber" type="xs:string" minOccurs="0" /> <xs:element name="recordingEntity" type="xs:string" minOccurs="0" /> <xs:element name="msClassmark" type="xs:string" minOccurs="0" /> <xs:element name="answerTime" type="xs:string" minOccurs="0" /> <xs:element name="releaseTime" type="xs:string" minOccurs="0" /> <xs:element name="callDuration" type="xs:string" minOccurs="0" /> <xs:element name="causeForTerm" type="xs:string" minOccurs="0" /> <xs:element name="callReference" type="xs:string" minOccurs="0" /> <xs:element name="gsm-SCFAddress" type="xs:string" minOccurs="0" /> <xs:element name="serviceKey" type="xs:string" minOccurs="0" /> <xs:element name="networkCallReference" type="xs:string" minOccurs="0" /> <xs:element name="mSCAddress" type="xs:string" minOccurs="0" /> <xs:element name="speechVersionSupported" type="xs:string" minOccurs="0" /> <xs:element name="speechVersionUsed" type="xs:string" minOccurs="0" /> <xs:element name="numberOfDPEncountered" type="xs:string" minOccurs="0" /> <xs:element name="levelOfCAMELService" type="xs:string" minOccurs="0" /> <xs:element name="freeFormatData" type="xs:string" minOccurs="0" /> <xs:element name="classmark3" type="xs:string" minOccurs="0" /> <xs:element name="mscOutgoingCircuit" type="xs:string" minOccurs="0" /> <xs:element name="orgRNCorBSCId" type="xs:string" minOccurs="0" /> <xs:element name="orgMSCId" type="xs:string" minOccurs="0" /> <xs:element name="calledIMSI" type="xs:string" minOccurs="0" /> <xs:element name="globalAreaID" type="xs:string" minOccurs="0" /> <xs:element name="subscriberCategory" type="xs:string" minOccurs="0" /> <xs:element name="firstmccmnc" type="xs:string" minOccurs="0" /> <xs:element name="lastmccmnc" type="xs:string" minOccurs="0" /> <xs:element ref="mscIncomingROUTE" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="mscOutgoingROUTE" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="location" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="basicService" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="radioChanRequested" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="radioChanUsed" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="diagnostics" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="additionalChgInfo" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="systemType" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="chargedParty" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="mtCallRecord" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="recordType" type="xs:string" minOccurs="0" /> <xs:element name="servedIMSI" type="xs:string" minOccurs="0" /> <xs:element name="servedIMEI" type="xs:string" minOccurs="0" /> <xs:element name="servedMSISDN" type="xs:string" minOccurs="0" /> <xs:element name="callingNumber" type="xs:string" minOccurs="0" /> <xs:element name="recordingEntity" type="xs:string" minOccurs="0" /> <xs:element name="msClassmark" type="xs:string" minOccurs="0" /> <xs:element name="answerTime" type="xs:string" minOccurs="0" /> <xs:element name="releaseTime" type="xs:string" minOccurs="0" /> <xs:element name="callDuration" type="xs:string" minOccurs="0" /> <xs:element name="causeForTerm" type="xs:string" minOccurs="0" /> <xs:element name="callReference" type="xs:string" minOccurs="0" /> <xs:element name="networkCallReference" type="xs:string" minOccurs="0" /> <xs:element name="mSCAddress" type="xs:string" minOccurs="0" /> <xs:element name="speechVersionSupported" type="xs:string" minOccurs="0" /> <xs:element name="speechVersionUsed" type="xs:string" minOccurs="0" /> <xs:element name="classmark3" type="xs:string" minOccurs="0" /> <xs:element name="roamingNumber" type="xs:string" minOccurs="0" /> <xs:element name="mscIncomingCircuit" type="xs:string" minOccurs="0" /> <xs:element name="orgRNCorBSCId" type="xs:string" minOccurs="0" /> <xs:element name="orgMSCId" type="xs:string" minOccurs="0" /> <xs:element name="globalAreaID" type="xs:string" minOccurs="0" /> <xs:element name="subscriberCategory" type="xs:string" minOccurs="0" /> <xs:element name="firstmccmnc" type="xs:string" minOccurs="0" /> <xs:element name="lastmccmnc" type="xs:string" minOccurs="0" /> <xs:element ref="mscIncomingROUTE" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="mscOutgoingROUTE" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="location" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="basicService" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="supplServicesUsed" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="SuppServiceUsedid" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="ssCode" type="xs:string" minOccurs="0" /> <xs:element name="ssTime" type="xs:string" minOccurs="0" /> </xs:sequence>

    Read the article

  • C++ Check Substring of a String

    - by user69514
    I'm trying to check whether or not the second argument in my program is a substring of the first argument. The problem is that it only work if the substring starts with the same letter of the string. .i.e Michigan - Mich (this works) Michigan - Mi (this works) Michigan - igan (this doesn't work) #include <stdio.h> #include <string.h> #include <string> using namespace std; bool my_strstr( string str, string sub ) { bool flag = true; int startPosition = -1; char subStart = str.at(0); char strStart; //find starting position for(int i=0; i<str.length(); i++){ if(str.at(i) == subStart){ startPosition = i; break; } } for(int i=0; i<sub.size(); i++){ if(sub.at(i) != str.at(startPosition)){ flag = false; break; } startPosition++; } return flag; } int main(int argc, char **argv){ if (argc != 3) { printf ("Usage: check <string one> <string two>\n"); } string str1 = argv[1]; string str2 = argv[2]; bool result = my_strstr(str1, str2); if(result == 1){ printf("%s is a substring of %s\n", argv[2], argv[1]); } else{ printf("%s is not a substring of %s\n", argv[2], argv[1]); } return 0; }

    Read the article

  • How to restrict a content of string to less than 4MB and save that string in DB using C#

    - by Pranay B
    I'm working on a project where I need to get the Text data from pdf files and dump the whole text in a DB column. With the help of iTextsharp, I got the data and referred it String. But now I need to check whether the string exceeds the 4MB limit or not and if it is exceeding then accept the string data which is less than 4MB in size. This is my code: internal string ReadPdfFiles() { // variable to store file path string filePath = null; // open dialog box to select file OpenFileDialog file = new OpenFileDialog(); // dilog box title name file.Title = "Select Pdf File"; //files to be accepted by the user. file.Filter = "Pdf file (*.pdf)|*.pdf|All files (*.*)|*.*"; // set initial directory of computer system file.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); // set restore directory file.RestoreDirectory = true; // execute if block when dialog result box click ok button if (file.ShowDialog() == DialogResult.OK) { // store selected file path filePath = file.FileName.ToString(); } //file path /// use a string array and pass all the pdf for searching //String filePath = @"D:\Pranay\Documentation\Working on SSAS.pdf"; try { //creating an instance of PdfReader class using (PdfReader reader = new PdfReader(filePath)) { //creating an instance of StringBuilder class StringBuilder text = new StringBuilder(); //use loop to specify how many pages to read. //I started from 5th page as Piyush told for (int i = 5; i <= reader.NumberOfPages; i++) { //Read the pdf text.Append(PdfTextExtractor.GetTextFromPage(reader, i)); }//end of for(i) int k = 4096000; //Test whether the string exceeds the 4MB if (text.Length < k) { //return the string text1 = text.ToString(); } //end of if } //end of using } //end try catch (Exception ex) { MessageBox.Show(ex.Message, "Please Do select a pdf file!!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } //end of catch return text1; } //end of ReadPdfFiles() method Do help me!

    Read the article

  • string comparision and counting the key in target [closed]

    - by mesun
    Suppose we want to count the number of times that a key string appears in a target string. We are going to create two different functions to accomplish this task: one iterative, and one recursive. For both functions, you can rely on Python's find function - you should read up on its specifications to see how to provide optional arguments to start the search for a match at a location other than the beginning of the string. For example, find("atgacatgcacaagtatgcat","atgc") #returns the value 5, while find("atgacatgcacaagtatgcat","atgc",6) #returns the value 15, meaning that by starting the search at index 6, #the next match is found at location 15. For the recursive version, you will want to think about how to use your function on a smaller version of the same problem (e.g., on a smaller target string) and then how to combine the result of that computation to solve the original problem. For example, given you can find the first instance of a key string in a target string, how would you combine that result with invocation of the same function on a smaller target string? You may find the string slicing operation useful in getting substrings of string.

    Read the article

  • Get context for search string in text in C#

    - by soundslike
    Given a string text which contains newline there is a search keyword which matches an item within the text. How do I implement the following in C#: searchIdx = search index (starting with 0, then 1, etc. for each successive call to GetSearchContext. Initially start with 0. contextsTxt = string data to search in searchTxt = keyword to search for in contextsTxt numLines = number of lines to return surrounding the searchTxt found (ie. 1 = the line the searchTxt is found on, 2 = the line the searchTxt is found on, 3 = the line above the searchTxt is found on, the line the searchTxt is found on, and the line below the searchTxt is found on) returns the "context" based on the parameters string GetSearchContext(int searchIdx, string contentsTxt, string searchTxt, int numLines); If there's a better function interface to accomplish this feel free to suggest that as well. I tried the following but doesn't seem to work properly all the time: private string GetSearchContext(string contentValue, string search, int numLines) { int searchIdx = contentValue.IndexOf(search); int startIdx = 0; int lastIdx = 0; while (startIdx != -1 && (startIdx = contentValue.IndexOf('\n', startIdx+1)) < searchIdx) { lastIdx = startIdx; } startIdx = lastIdx; if (startIdx < 0) startIdx = 0; int endIdx = searchIdx; int lineCnt = 0; while (endIdx != -1 && lineCnt++ < numLines) { endIdx = contentValue.IndexOf('\n', endIdx + 1); } if (endIdx == -1 || endIdx > contentValue.Length - 1) endIdx = contentValue.Length - 1; string lines = contentValue.Substring(startIdx, endIdx - startIdx + 1); if (lines[0] == '\n') lines = lines.Substring(1); if (lines[lines.Length - 1] == '\n') { lines = lines.Substring(0, lines.Length - 1); } if (lines[lines.Length - 1] == '\r') { lines = lines.Substring(0, lines.Length - 1); } return lines; }

    Read the article

  • java: decoding URI query string

    - by Jason S
    I need to decode a URI that contains a query string; expected input/output behavior is something like the following: abstract class URIParser { /** example input: * something?alias=pos&FirstName=Foo+A%26B%3DC&LastName=Bar */ URIParser(String input) { ... } /** should return "something" for the example input */ public String getPath(); /** should return a map * {alias: "pos", FirstName: "Foo+A&B=C", LastName: "Bar"} */ public Map<String,String> getQuery(); } I've tried using java.net.URI, but it seems to decode the query string so in the above example I'm left with "alias=pos&FirstName=Foo+A&B=C&LastName=Bar" so there is ambiguity whether a "&" is a query separator or is a character in a query component. edit: just tried URI.getRawQuery() and it doesn't do the encoding, so I can split the query string with a "&", but then what do I do? Any suggestions?

    Read the article

  • Java: Print and access List <String[]>

    - by battousai622
    Im reading in a file and storing it in t1. How do i access the elements in t1? When i try to print it i get addresses instead of values. Also whats the dif between string and string[]? CSVReader reader = new CSVReader(new FileReader("src/new_acquisitions.csv")); List <String[]> t1 = reader.readAll(); int i = 0 while(i < t1.size()) { System.out.println(t1.get(i)); i++; } output: [Ljava.lang.String;@9304b1 [Ljava.lang.String;@190d11 [Ljava.lang.String;@a90653 [Ljava.lang.String;@de6ced

    Read the article

  • Optimizing MySQL update query

    - by Jernej Jerin
    This is currently my MySQL UPDATE query, which is called from program written in Java: String query = "UPDATE maxday SET DatePressureREL = (SELECT Date FROM ws3600 WHERE PressureREL = (SELECT MAX" + "(PressureREL) FROM ws3600 WHERE Date >= '" + Date + "') AND Date >= '" + Date + "' ORDER BY Date DESC LIMIT 1), " + "PressureREL = (SELECT PressureREL FROM ws3600 WHERE PressureREL = (SELECT MAX(PressureREL) FROM ws3600 " + "WHERE Date >= '" + Date + "') AND Date >= '" + Date + "' ORDER BY Date DESC LIMIT 1), ..."; try { s.execute(query); } catch (SQLException e) { System.out.println("SQL error"); } catch(Exception e) { e.printStackTrace(); } Let me explain first, what does it do. I have two tables, first is ws3600, which holds columns (Date, PressureREL, TemperatureOUT, Dewpoint, ...). Then I have second table, called maxday, which holds columns like DatePressureREL, PressureREL, DateTemperatureOUT, TemperatureOUT,... Now as you can see from an example, I update each column, the question is, is there a faster way? I am asking this, because I am calling MAX twice, first to find the Date for that value and secondly to find the actual value. Now I know that I could write like that: SELECT Date, PressureREL FROM ws3600 WHERE PressureREL = (SELECT MAX(PressureREL) FROM ws3600 WHERE Date >= '" + Date + "') AND Date >= '" + Date + "' ORDER BY Date DESC LIMIT 1 That way I get the Date of the max and the max value at the same time and then update with those values the data in maxday table. But the problem of this solution is, that I have to execute many queries, which as I understand takes alot more time compared to executing one long mysql query because of overhead in sending each query to the server. If there is no better way, which solution beetwen this two should I choose. The first, which only takes one query but is very unoptimized or the second which is beter in terms of optimization, but needs alot more queries which probably means that the preformance gain is lost because of overhead in sending each query to the server?

    Read the article

  • return new string vs .ToString()

    - by Leroy Jenkins
    Take the following code: public static string ReverseIt(string myString) { char[] foo = myString.ToCharArray(); Array.Reverse(foo); return new string(foo); } I understand that strings are immutable, but what I dont understand is why a new string needs to be called return new string(foo); instead of return foo.ToString(); I have to assume it has something to do with reassembling the CharArray (but thats just a guess). Whats the difference between the two and how do you know when to return a new string as opposed to returning a System.String that represents the current object?

    Read the article

  • Mysql - What's wrong with the query...?

    - by SpikETidE
    Hi everybody.... I am trying to query a database to find the following If a customer searches for a hotel in a city between dates A and B, find and return the hotels in which rooms are free between the two dates. There will be more than one room in each room type(i.e. 5 Rooms in type A, 10 rooms in Type B etc) and we have to query the db to find only those hotels in which there is atleast one room free in atleast one type. This is my table structure.... **Structure for table 'reservations'** reservation_id hotel_id room_id customer_id payment_id no_of_rooms check_in_date check_out_date reservation_date **Structure for table 'hotels'** hotel_id hotel_name hotel_description hotel_address hotel_location hotel_country hotel_city hotel_type hotel_stars hotel_image hotel_deleted **Structure for table 'rooms'** room_id hotel_id room_name max_persons total_rooms room_price room_image agent_commision room_facilities service_tax vat city_tax room_description room_deleted And this is my query $city_search = '15'; $check_in_date = '29-03-2010'; $check_out_date = '31-03-2010'; $dateFormat_check_in = "DATE_FORMAT('$reservations.check_in_date','%d-%m-%Y')"; $dateFormat_check_out = "DATE_FORMAT('$reservations.check_out_date','%d-%m-%Y')"; $dateCheck = "$dateFormat_check_in >= '$check_in_date' AND $dateFormat_check_out <= '$check_out_date'"; $query = "SELECT $rooms.room_id, $rooms.room_name, $rooms.max_persons, $rooms.room_price, $hotels.hotel_id, $hotels.hotel_name, $hotels.hotel_stars, $hotels.hotel_type FROM $hotels,$rooms,$reservations WHERE $hotels.hotel_city = '$city_search' AND $hotels.hotel_id = $rooms.hotel_id AND $hotels.hotel_deleted = '0' AND $rooms.room_deleted = '0' AND $rooms.total_rooms - (SELECT SUM($reservations.no_of_rooms) as tot FROM $reservations WHERE $dateCheck GROUP BY $reservations.room_id) > '0'"; The number of rooms already reserved in each room type in each hotel will be stored in the reservations table... The thing is the query doesn't return any result at all...even though it should if i calculate it myself manually... I tried running the sub-query alone and i don't get any result... And i have lost quite some amount of hair trying to de-bug this query from yesterday... What's wrong with this...? Or is there a better way to do what i mentioned above...? Thanks for your time... Edit : Code edited to remove an bud... thanks to

    Read the article

  • Formatting a string in Java using class attributes

    - by Jason R. Coombs
    I have a class with an attribute and getter method: public Class MyClass { private String myValue = "foo"; public String getMyValue(); } I would like to be able to use the value of foo in a formatted string as such: String someString = "Your value is {myValue}." String result = Formatter.format(someString, new MyClass()); // result is now "Your value is foo." That is, I would like to have some function like .format above which takes a format string specifying properties on some object, and an instance with those properties, and formats the string accordingly. Is it possible to do accomplish this feat in Java?

    Read the article

  • Change date in a SQL query to reference a cell in Excel

    - by Adil
    I have the following code that returns the needed data into excel and manually changing the date will change the returned data; however, I'd like to reference a cell with a formula that will make the query a bit more user friendly. I've tried using my limited knowledge of referencing a cell but none have worked. This information is in cell A1 and the query is placed in cell A2 with the following equation: =wwQuery("STKAP03", $A$1) SET QUOTED_IDENTIFIER OFF SELECT * FROM OPENQUERY(INSQL, "SELECT DateTime, [40_MOTORS.MI436423.CIN], [40_MOTORS.MI436425.CIN] FROM WideHistory WHERE [40_MOTORS.MI436423.CIN] IS NOT NULL AND wwRetrievalMode = 'Delta' AND wwVersion = 'Latest' AND DateTime >='20120409 07:00:00' These two dates/times I'd like to reference cells on a different sheet AND DateTime <= '20120416 07:00:00'")

    Read the article

  • Output problem in mysql query in MFC program

    - by D.Gaughan
    Im currently working on a small MFC program that outputs data from a mysql database. I can get output when im using an sql statement that does not contain any variable eg. select album from Artists; but when i try to use a variable the program compiles but i get no output eg. mysql_perform_query(conn,select album from Artists where artists = '"+m_search_edit"'") Here is the function for mysql_perform_query: MYSQL_RES* mysql_perform_query(MYSQL *conn, const char* query) { // send the query to the database if (mysql_query(conn, query)) { // printf("MySQL query error : %s\n", mysql_error(conn)); // exit(1); } return mysql_use_result(conn); } And here is the code block for outputting the data: struct connection_details mysqlD; mysqlD.server = "www.freesqldatabase.com"; // where the mysql database is mysqlD.user = "**********"; // the root user of mysql mysqlD.password = "***********"; // the password of the root user in mysql mysqlD.database = "***************"; // the databse to pick // connect to the mysql database conn = mysql_connection_setup(mysqlD); CStringA query; query.Format("select album from Artists where artist = '%s'", CT2CA(m_search_edit)); res = mysql_perform_query(conn, query); //res = mysql_perform_query (conn, "select distinct artist from Artists"); while((row = mysql_fetch_row(res)) != NULL){ CString str; UpdateData(); str = ("%s\n", row[0]); UpdateData(FALSE); m_list_control.AddString(str); } The m_search_edit variable is the variable for an edit box. I am using Visual Studio 2008 with one copy of this program unicode and one nonunicode, I also have a version built with VC++ 6. Any tips on how I can get output from the databse using the m_search_edit variable??

    Read the article

  • PHP strip_tags only at the end of the string

    - by Solomon Closson
    Ok, well, I just want to use strip_tags function on the very end of a string to get rid of any <br /> tags. Here's what I have now, but this is no good because it strips these tags from everywhere in the string, which is not what I want. I only need them stripped out if it's at the end of the string... $string = strip_tags($string, strtr($string, array('<br />' => '&#10;'))); How can I do this same thing, except only at the very end of a string?? Thanks guys!!

    Read the article

  • Only show items owned by the currently logged in user in category list view

    - by jalbasri
    I'd like to be able to provide a "Category List" view that only shows Articles that the currently logged in user owns. Is there somewhere I can edit the query used to populate the Category List view or an extension that provides this functionality. Thank you for any help you can provide. -J. Thank you for your answer. I've written the plugin. Instead of passing in an array of Articles the onContentBeforeDisplay function is called for every article and an ArrayObject of the single article gets passed in. I've been able to identify the articles I want not to be displayed but still cannot get them not to display. The $params variable has values such as "list_show_xxx" but I can't seem to change or access them. here is a var_dump($params): object(Joomla\Registry\Registry)#190 (1) { ["data":protected]=> object(stdClass)#250 (83) { ["article_layout"]=> string(9) "_:default" ["show_title"]=> string(1) "1" ["link_titles"]=> string(1) "1" ["show_intro"]=> string(1) "1" ["info_block_position"]=> string(1) "1" ["show_category"]=> string(1) "1" ["link_category"]=> string(1) "1" ["show_parent_category"]=> string(1) "0" ["link_parent_category"]=> string(1) "0" ["show_author"]=> string(1) "1" ["link_author"]=> string(1) "0" ["show_create_date"]=> string(1) "0" ["show_modify_date"]=> string(1) "0" ["show_publish_date"]=> string(1) "1" ["show_item_navigation"]=> string(1) "1" ["show_vote"]=> string(1) "0" ["show_readmore"]=> string(1) "1" ["show_readmore_title"]=> string(1) "1" ["readmore_limit"]=> string(3) "100" ["show_tags"]=> string(1) "1" ["show_icons"]=> string(1) "1" ["show_print_icon"]=> string(1) "1" ["show_email_icon"]=> string(1) "1" ["show_hits"]=> string(1) "1" ["show_noauth"]=> string(1) "0" ["urls_position"]=> string(1) "0" ["show_publishing_options"]=> string(1) "0" ["show_article_options"]=> string(1) "0" ["save_history"]=> string(1) "1" ["history_limit"]=> int(10) ["show_urls_images_frontend"]=> string(1) "0" ["show_urls_images_backend"]=> string(1) "1" ["targeta"]=> int(0) ["targetb"]=> int(0) ["targetc"]=> int(0) ["float_intro"]=> string(4) "left" ["float_fulltext"]=> string(4) "left" ["category_layout"]=> string(9) "_:default" ["show_category_heading_title_text"]=> string(1) "1" ["show_category_title"]=> string(1) "0" ["show_description"]=> string(1) "0" ["show_description_image"]=> string(1) "0" ["maxLevel"]=> string(1) "1" ["show_empty_categories"]=> string(1) "0" ["show_no_articles"]=> string(1) "1" ["show_subcat_desc"]=> string(1) "1" ["show_cat_num_articles"]=> string(1) "0" ["show_base_description"]=> string(1) "1" ["maxLevelcat"]=> string(2) "-1" ["show_empty_categories_cat"]=> string(1) "0" ["show_subcat_desc_cat"]=> string(1) "1" ["show_cat_num_articles_cat"]=> string(1) "1" ["num_leading_articles"]=> string(1) "1" ["num_intro_articles"]=> string(1) "4" ["num_columns"]=> string(1) "1" ["num_links"]=> string(1) "4" ["multi_column_order"]=> string(1) "0" ["show_subcategory_content"]=> string(1) "0" ["show_pagination_limit"]=> string(1) "1" ["filter_field"]=> string(5) "title" ["show_headings"]=> string(1) "1" ["list_show_date"]=> string(1) "0" ["date_format"]=> string(0) "" ["list_show_hits"]=> string(1) "1" ["list_show_author"]=> string(1) "1" ["orderby_pri"]=> string(5) "order" ["orderby_sec"]=> string(5) "rdate" ["order_date"]=> string(9) "published" ["show_pagination"]=> string(1) "2" ["show_pagination_results"]=> string(1) "1" ["show_feed_link"]=> string(1) "1" ["feed_summary"]=> string(1) "0" ["feed_show_readmore"]=> string(1) "0" ["display_num"]=> string(2) "10" ["menu_text"]=> int(1) ["show_page_heading"]=> int(0) ["secure"]=> int(0) ["page_title"]=> string(16) "Non-K2 News List" ["page_description"]=> string(33) "Bahrain Business Incubator Centre" ["page_rights"]=> NULL ["robots"]=> NULL ["access-edit"]=> bool(true) ["access-view"]=> bool(true) } } I've tried $params-data-list_show_author = "0" but then the page doesn't load, problem is accessing and changing the variables in $param. So the last step is to figure out how not to show the article. Any ideas?

    Read the article

  • Parsing String to TreeNode

    - by Krusu70
    Anyone have a good algorithm how to parse a String to TreeNode in Java? Let's say we have a string s which says how to build a TreeNode. A(B,C) means that A is the name (String) of TreeNode, B is child of A (Treenode), C is sibling of A (TreeNode). So if I call function with string A(B(D,E(F,G)),C) (just a example), then I get a TreeNode equals to: level A (String: name), B - Child (TreeNode), C - Sibling (TreeNode) level B (String: name), D - Child of B (TreeNode), E - Sibling of B (TreeNode) level E (String: name), F - Child of E (TreeNode), G - Sibling of E (TreeNode) The name may not be 1 letter, it could be like real name (many letters).

    Read the article

  • Trimming byte array when converting byte array to string in Java/Scala

    - by prosseek
    Using ByteBuffer, I can convert a string into byte array: val x = ByteBuffer.allocate(10).put("Hello".getBytes()).array() > Array[Byte] = Array(104, 101, 108, 108, 111, 0, 0, 0, 0, 0) When converting the byte array into string, I can use new String(x). However, the string becomes hello?????, and I need to trim down the byte array before converting it into string. How can I do that? I use this code to trim down the zeros, but I wonder if there is simpler way. def byteArrayToString(x: Array[Byte]) = { val loc = x.indexOf(0) if (-1 == loc) new String(x) else if (0 == loc) "" else new String(x.slice(0,loc)) }

    Read the article

  • Rendering ASP.NET MVC Views to String

    - by Rick Strahl
    It's not uncommon in my applications that I require longish text output that does not have to be rendered into the HTTP output stream. The most common scenario I have for 'template driven' non-Web text is for emails of all sorts. Logon confirmations and verifications, email confirmations for things like orders, status updates or scheduler notifications - all of which require merged text output both within and sometimes outside of Web applications. On other occasions I also need to capture the output from certain views for logging purposes. Rather than creating text output in code, it's much nicer to use the rendering mechanism that ASP.NET MVC already provides by way of it's ViewEngines - using Razor or WebForms views - to render output to a string. This is nice because it uses the same familiar rendering mechanism that I already use for my HTTP output and it also solves the problem of where to store the templates for rendering this content in nothing more than perhaps a separate view folder. The good news is that ASP.NET MVC's rendering engine is much more modular than the full ASP.NET runtime engine which was a real pain in the butt to coerce into rendering output to string. With MVC the rendering engine has been separated out from core ASP.NET runtime, so it's actually a lot easier to get View output into a string. Getting View Output from within an MVC Application If you need to generate string output from an MVC and pass some model data to it, the process to capture this output is fairly straight forward and involves only a handful of lines of code. The catch is that this particular approach requires that you have an active ControllerContext that can be passed to the view. This means that the following approach is limited to access from within Controller methods. Here's a class that wraps the process and provides both instance and static methods to handle the rendering:/// <summary> /// Class that renders MVC views to a string using the /// standard MVC View Engine to render the view. /// /// Note: This class can only be used within MVC /// applications that have an active ControllerContext. /// </summary> public class ViewRenderer { /// <summary> /// Required Controller Context /// </summary> protected ControllerContext Context { get; set; } public ViewRenderer(ControllerContext controllerContext) { Context = controllerContext; } /// <summary> /// Renders a full MVC view to a string. Will render with the full MVC /// View engine including running _ViewStart and merging into _Layout /// </summary> /// <param name="viewPath"> /// The path to the view to render. Either in same controller, shared by /// name or as fully qualified ~/ path including extension /// </param> /// <param name="model">The model to render the view with</param> /// <returns>String of the rendered view or null on error</returns> public string RenderView(string viewPath, object model) { return RenderViewToStringInternal(viewPath, model, false); } /// <summary> /// Renders a partial MVC view to string. Use this method to render /// a partial view that doesn't merge with _Layout and doesn't fire /// _ViewStart. /// </summary> /// <param name="viewPath"> /// The path to the view to render. Either in same controller, shared by /// name or as fully qualified ~/ path including extension /// </param> /// <param name="model">The model to pass to the viewRenderer</param> /// <returns>String of the rendered view or null on error</returns> public string RenderPartialView(string viewPath, object model) { return RenderViewToStringInternal(viewPath, model, true); } public static string RenderView(string viewPath, object model, ControllerContext controllerContext) { ViewRenderer renderer = new ViewRenderer(controllerContext); return renderer.RenderView(viewPath, model); } public static string RenderPartialView(string viewPath, object model, ControllerContext controllerContext) { ViewRenderer renderer = new ViewRenderer(controllerContext); return renderer.RenderPartialView(viewPath, model); } protected string RenderViewToStringInternal(string viewPath, object model, bool partial = false) { // first find the ViewEngine for this view ViewEngineResult viewEngineResult = null; if (partial) viewEngineResult = ViewEngines.Engines.FindPartialView(Context, viewPath); else viewEngineResult = ViewEngines.Engines.FindView(Context, viewPath, null); if (viewEngineResult == null) throw new FileNotFoundException(Properties.Resources.ViewCouldNotBeFound); // get the view and attach the model to view data var view = viewEngineResult.View; Context.Controller.ViewData.Model = model; string result = null; using (var sw = new StringWriter()) { var ctx = new ViewContext(Context, view, Context.Controller.ViewData, Context.Controller.TempData, sw); view.Render(ctx, sw); result = sw.ToString(); } return result; } } The key is the RenderViewToStringInternal method. The method first tries to find the view to render based on its path which can either be in the current controller's view path or the shared view path using its simple name (PasswordRecovery) or alternately by its full virtual path (~/Views/Templates/PasswordRecovery.cshtml). This code should work both for Razor and WebForms views although I've only tried it with Razor Views. Note that WebForms Views might actually be better for plain text as Razor adds all sorts of white space into its output when there are code blocks in the template. The Web Forms engine provides more accurate rendering for raw text scenarios. Once a view engine is found the view to render can be retrieved. Views in MVC render based on data that comes off the controller like the ViewData which contains the model along with the actual ViewData and ViewBag. From the View and some of the Context data a ViewContext is created which is then used to render the view with. The View picks up the Model and other data from the ViewContext internally and processes the View the same it would be processed if it were to send its output into the HTTP output stream. The difference is that we can override the ViewContext's output stream which we provide and capture into a StringWriter(). After rendering completes the result holds the output string. If an error occurs the error behavior is similar what you see with regular MVC errors - you get a full yellow screen of death including the view error information with the line of error highlighted. It's your responsibility to handle the error - or let it bubble up to your regular Controller Error filter if you have one. To use the simple class you only need a single line of code if you call the static methods. Here's an example of some Controller code that is used to send a user notification to a customer via email in one of my applications:[HttpPost] public ActionResult ContactSeller(ContactSellerViewModel model) { InitializeViewModel(model); var entryBus = new busEntry(); var entry = entryBus.LoadByDisplayId(model.EntryId); if ( string.IsNullOrEmpty(model.Email) ) entryBus.ValidationErrors.Add("Email address can't be empty.","Email"); if ( string.IsNullOrEmpty(model.Message)) entryBus.ValidationErrors.Add("Message can't be empty.","Message"); model.EntryId = entry.DisplayId; model.EntryTitle = entry.Title; if (entryBus.ValidationErrors.Count > 0) { ErrorDisplay.AddMessages(entryBus.ValidationErrors); ErrorDisplay.ShowError("Please correct the following:"); } else { string message = ViewRenderer.RenderView("~/views/template/ContactSellerEmail.cshtml",model, ControllerContext); string title = entry.Title + " (" + entry.DisplayId + ") - " + App.Configuration.ApplicationName; AppUtils.SendEmail(title, message, model.Email, entry.User.Email, false, false)) } return View(model); } Simple! The view in this case is just a plain MVC view and in this case it's a very simple plain text email message (edited for brevity here) that is created and sent off:@model ContactSellerViewModel @{ Layout = null; }re: @Model.EntryTitle @Model.ListingUrl @Model.Message ** SECURITY ADVISORY - AVOID SCAMS ** Avoid: wiring money, cross-border deals, work-at-home ** Beware: cashier checks, money orders, escrow, shipping ** More Info: @(App.Configuration.ApplicationBaseUrl)scams.html Obviously this is a very simple view (I edited out more from this page to keep it brief) -  but other template views are much more complex HTML documents or long messages that are occasionally updated and they are a perfect fit for Razor rendering. It even works with nested partial views and _layout pages. Partial Rendering Notice that I'm rendering a full View here. In the view I explicitly set the Layout=null to avoid pulling in _layout.cshtml for this view. This can also be controlled externally by calling the RenderPartial method instead: string message = ViewRenderer.RenderPartialView("~/views/template/ContactSellerEmail.cshtml",model, ControllerContext); with this line of code no layout page (or _viewstart) will be loaded, so the output generated is just what's in the view. I find myself using Partials most of the time when rendering templates, since the target of templates usually tend to be emails or other HTML fragment like output, so the RenderPartialView() method is definitely useful to me. Rendering without a ControllerContext The preceding class is great when you're need template rendering from within MVC controller actions or anywhere where you have access to the request Controller. But if you don't have a controller context handy - maybe inside a utility function that is static, a non-Web application, or an operation that runs asynchronously in ASP.NET - which makes using the above code impossible. I haven't found a way to manually create a Controller context to provide the ViewContext() what it needs from outside of the MVC infrastructure. However, there are ways to accomplish this,  but they are a bit more complex. It's possible to host the RazorEngine on your own, which side steps all of the MVC framework and HTTP and just deals with the raw rendering engine. I wrote about this process in Hosting the Razor Engine in Non-Web Applications a long while back. It's quite a process to create a custom Razor engine and runtime, but it allows for all sorts of flexibility. There's also a RazorEngine CodePlex project that does something similar. I've been meaning to check out the latter but haven't gotten around to it since I have my own code to do this. The trick to hosting the RazorEngine to have it behave properly inside of an ASP.NET application and properly cache content so templates aren't constantly rebuild and reparsed. Anyway, in the same app as above I have one scenario where no ControllerContext is available: I have a background scheduler running inside of the app that fires on timed intervals. This process could be external but because it's lightweight we decided to fire it right inside of the ASP.NET app on a separate thread. In my app the code that renders these templates does something like this:var model = new SearchNotificationViewModel() { Entries = entries, Notification = notification, User = user }; // TODO: Need logging for errors sending string razorError = null; var result = AppUtils.RenderRazorTemplate("~/views/template/SearchNotificationTemplate.cshtml", model, razorError); which references a couple of helper functions that set up my RazorFolderHostContainer class:public static string RenderRazorTemplate(string virtualPath, object model,string errorMessage = null) { var razor = AppUtils.CreateRazorHost(); var path = virtualPath.Replace("~/", "").Replace("~", "").Replace("/", "\\"); var merged = razor.RenderTemplateToString(path, model); if (merged == null) errorMessage = razor.ErrorMessage; return merged; } /// <summary> /// Creates a RazorStringHostContainer and starts it /// Call .Stop() when you're done with it. /// /// This is a static instance /// </summary> /// <param name="virtualPath"></param> /// <param name="binBasePath"></param> /// <param name="forceLoad"></param> /// <returns></returns> public static RazorFolderHostContainer CreateRazorHost(string binBasePath = null, bool forceLoad = false) { if (binBasePath == null) { if (HttpContext.Current != null) binBasePath = HttpContext.Current.Server.MapPath("~/"); else binBasePath = AppDomain.CurrentDomain.BaseDirectory; } if (_RazorHost == null || forceLoad) { if (!binBasePath.EndsWith("\\")) binBasePath += "\\"; //var razor = new RazorStringHostContainer(); var razor = new RazorFolderHostContainer(); razor.TemplatePath = binBasePath; binBasePath += "bin\\"; razor.BaseBinaryFolder = binBasePath; razor.UseAppDomain = false; razor.ReferencedAssemblies.Add(binBasePath + "ClassifiedsBusiness.dll"); razor.ReferencedAssemblies.Add(binBasePath + "ClassifiedsWeb.dll"); razor.ReferencedAssemblies.Add(binBasePath + "Westwind.Utilities.dll"); razor.ReferencedAssemblies.Add(binBasePath + "Westwind.Web.dll"); razor.ReferencedAssemblies.Add(binBasePath + "Westwind.Web.Mvc.dll"); razor.ReferencedAssemblies.Add("System.Web.dll"); razor.ReferencedNamespaces.Add("System.Web"); razor.ReferencedNamespaces.Add("ClassifiedsBusiness"); razor.ReferencedNamespaces.Add("ClassifiedsWeb"); razor.ReferencedNamespaces.Add("Westwind.Web"); razor.ReferencedNamespaces.Add("Westwind.Utilities"); _RazorHost = razor; _RazorHost.Start(); //_RazorHost.Engine.Configuration.CompileToMemory = false; } return _RazorHost; } The RazorFolderHostContainer essentially is a full runtime that mimics a folder structure like a typical Web app does including caching semantics and compiling code only if code changes on disk. It maps a folder hierarchy to views using the ~/ path syntax. The host is then configured to add assemblies and namespaces. Unfortunately the engine is not exactly like MVC's Razor - the expression expansion and code execution are the same, but some of the support methods like sections, helpers etc. are not all there so templates have to be a bit simpler. There are other folder hosts provided as well to directly execute templates from strings (using RazorStringHostContainer). The following is an example of an HTML email template @inherits RazorHosting.RazorTemplateFolderHost <ClassifiedsWeb.SearchNotificationViewModel> <html> <head> <title>Search Notifications</title> <style> body { margin: 5px;font-family: Verdana, Arial; font-size: 10pt;} h3 { color: SteelBlue; } .entry-item { border-bottom: 1px solid grey; padding: 8px; margin-bottom: 5px; } </style> </head> <body> Hello @Model.User.Name,<br /> <p>Below are your Search Results for the search phrase:</p> <h3>@Model.Notification.SearchPhrase</h3> <small>since @TimeUtils.ShortDateString(Model.Notification.LastSearch)</small> <hr /> You can see that the syntax is a little different. Instead of the familiar @model header the raw Razor  @inherits tag is used to specify the template base class (which you can extend). I took a quick look through the feature set of RazorEngine on CodePlex (now Github I guess) and the template implementation they use is closer to MVC's razor but there are other differences. In the end don't expect exact behavior like MVC templates if you use an external Razor rendering engine. This is not what I would consider an ideal solution, but it works well enough for this project. My biggest concern is the overhead of hosting a second razor engine in a Web app and the fact that here the differences in template rendering between 'real' MVC Razor views and another RazorEngine really are noticeable. You win some, you lose some It's extremely nice to see that if you have a ControllerContext handy (which probably addresses 99% of Web app scenarios) rendering a view to string using the native MVC Razor engine is pretty simple. Kudos on making that happen - as it solves a problem I see in just about every Web application I work on. But it is a bummer that a ControllerContext is required to make this simple code work. It'd be really sweet if there was a way to render views without being so closely coupled to the ASP.NET or MVC infrastructure that requires a ControllerContext. Alternately it'd be nice to have a way for an MVC based application to create a minimal ControllerContext from scratch - maybe somebody's been down that path. I tried for a few hours to come up with a way to make that work but gave up in the soup of nested contexts (MVC/Controller/View/Http). I suspect going down this path would be similar to hosting the ASP.NET runtime requiring a WorkerRequest. Brrr…. The sad part is that it seems to me that a View should really not require much 'context' of any kind to render output to string. Yes there are a few things that clearly are required like paths to the virtual and possibly the disk paths to the root of the app, but beyond that view rendering should not require much. But, no such luck. For now custom RazorHosting seems to be the only way to make Razor rendering go outside of the MVC context… Resources Full ViewRenderer.cs source code from Westwind.Web.Mvc library Hosting the Razor Engine for Non-Web Applications RazorEngine on GitHub© Rick Strahl, West Wind Technologies, 2005-2012Posted in ASP.NET   ASP.NET  MVC   Tweet !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs"); (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })();

    Read the article

  • Dynamically select field names in a query with Spring JDBCTemplate

    - by Francesco
    Hi, I have a problem with parameters replacing by Spring JdbcTemplate. I have this query : <bean id="fixQuery" class="java.lang.String"> <constructor-arg type="java.lang.String" value="select fa.id, fi.? from fix_ambulation fa left join fix_i18n fi on fa.translation_id = fi.id order by name" /> And this method : public List<FixAmbulation> readFixAmbulation(String locale) throws Exception { List<FixAmbulation> ambulations = this.getJdbcTemplate().query( fixQuery, new Object[] {locale.toLowerCase()}, ParameterizedBeanPropertyRowMapper .newInstance(FixAmbulation.class)); return ambulations; } And I'd like to have the ? filled with the string representing the locale the user is using. So if the user is brasilian I'd send him the column pt_br from the table fix_i18n, otherwise if he's american I'd send him the column en_us. What I get from this method is a PostgreSQL exception org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1" If I replace fi.? with just ? (the column name of the locale is unique, so if I run this query in the database it works just fine) what I get is that every object returned from method has the string locale into the field name. I.e. in name field I have "en_us". The only way to have it working I found was to change the method into : public List<FixAmbulation> readFixAmbulation(String locale) throws Exception { String query = "select fa.id, fi." + locale.toLowerCase() + " as name " + fixQuery; this.log.info("QUERY : " + query); List<FixAmbulation> ambulations = this.getJdbcTemplate().query( query, ParameterizedBeanPropertyRowMapper .newInstance(FixAmbulation.class)); return ambulations; } and setting fixQuery to : <bean id="fixQuery" class="java.lang.String"> <constructor-arg type="java.lang.String" value=" from telemedicina.fix_ambulation fa left join telemedicina.fix_i18n fi on fa.translation_id = fi.id order by name" /> </bean> My DAO extends Spring JdbcDaoSupport and works just fine for all other queries. What am I doing wrong?

    Read the article

  • Linq to LLBLGen query problem

    - by Jeroen Breuer
    Hello, I've got a Stored Procedure and i'm trying to convert it to a Linq to LLBLGen query. The query in Linq to LLBGen works, but when I trace the query which is send to sql server it is far from perfect. This is the Stored Procedure: ALTER PROCEDURE [dbo].[spDIGI_GetAllUmbracoProducts] -- Add the parameters for the stored procedure. @searchText nvarchar(255), @startRowIndex int, @maximumRows int, @sortExpression nvarchar(255) AS BEGIN SET @startRowIndex = @startRowIndex + 1 SET @searchText = '%' + @searchText + '%' -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- This is the query which will fetch all the UmbracoProducts. -- This query also supports paging and sorting. WITH UmbracoOverview As ( SELECT ROW_NUMBER() OVER( ORDER BY CASE WHEN @sortExpression = 'productName' THEN umbracoProduct.productName WHEN @sortExpression = 'productCode' THEN umbracoProduct.productCode END ASC, CASE WHEN @sortExpression = 'productName DESC' THEN umbracoProduct.productName WHEN @sortExpression = 'productCode DESC' THEN umbracoProduct.productCode END DESC ) AS row_num, umbracoProduct.umbracoProductId, umbracoProduct.productName, umbracoProduct.productCode FROM umbracoProduct INNER JOIN product ON umbracoProduct.umbracoProductId = product.umbracoProductId WHERE (umbracoProduct.productName LIKE @searchText OR umbracoProduct.productCode LIKE @searchText OR product.code LIKE @searchText OR product.description LIKE @searchText OR product.descriptionLong LIKE @searchText OR product.unitCode LIKE @searchText) ) SELECT UmbracoOverview.UmbracoProductId, UmbracoOverview.productName, UmbracoOverview.productCode FROM UmbracoOverview WHERE (row_num >= @startRowIndex AND row_num < (@startRowIndex + @maximumRows)) -- This query will count all the UmbracoProducts. -- This query is used for paging inside ASP.NET. SELECT COUNT (umbracoProduct.umbracoProductId) AS CountNumber FROM umbracoProduct INNER JOIN product ON umbracoProduct.umbracoProductId = product.umbracoProductId WHERE (umbracoProduct.productName LIKE @searchText OR umbracoProduct.productCode LIKE @searchText OR product.code LIKE @searchText OR product.description LIKE @searchText OR product.descriptionLong LIKE @searchText OR product.unitCode LIKE @searchText) END This is my Linq to LLBLGen query: using System.Linq.Dynamic; var q = ( from up in MetaData.UmbracoProduct join p in MetaData.Product on up.UmbracoProductId equals p.UmbracoProductId where up.ProductCode.Contains(searchText) || up.ProductName.Contains(searchText) || p.Code.Contains(searchText) || p.Description.Contains(searchText) || p.DescriptionLong.Contains(searchText) || p.UnitCode.Contains(searchText) select new UmbracoProductOverview { UmbracoProductId = up.UmbracoProductId, ProductName = up.ProductName, ProductCode = up.ProductCode } ).OrderBy(sortExpression); //Save the count in HttpContext.Current.Items. This value will only be saved during 1 single HTTP request. HttpContext.Current.Items["AllProductsCount"] = q.Count(); //Returns the results paged. return q.Skip(startRowIndex).Take(maximumRows).ToList<UmbracoProductOverview>(); This is my Initial expression to process: value(SD.LLBLGen.Pro.LinqSupportClasses.DataSource`1[Eurofysica.DB.EntityClasses.UmbracoProductEntity]).Join(value(SD.LLBLGen.Pro.LinqSupportClasses.DataSource`1[Eurofysica.DB.EntityClasses.ProductEntity]), up => up.UmbracoProductId, p => p.UmbracoProductId, (up, p) => new <>f__AnonymousType0`2(up = up, p = p)).Where(<>h__TransparentIdentifier0 => (((((<>h__TransparentIdentifier0.up.ProductCode.Contains(value(Eurofysica.BusinessLogic.BLL.Controllers.UmbracoProductController+<>c__DisplayClass1).searchText) || <>h__TransparentIdentifier0.up.ProductName.Contains(value(Eurofysica.BusinessLogic.BLL.Controllers.UmbracoProductController+<>c__DisplayClass1).searchText)) || <>h__TransparentIdentifier0.p.Code.Contains(value(Eurofysica.BusinessLogic.BLL.Controllers.UmbracoProductController+<>c__DisplayClass1).searchText)) || <>h__TransparentIdentifier0.p.Description.Contains(value(Eurofysica.BusinessLogic.BLL.Controllers.UmbracoProductController+<>c__DisplayClass1).searchText)) || <>h__TransparentIdentifier0.p.DescriptionLong.Contains(value(Eurofysica.BusinessLogic.BLL.Controllers.UmbracoProductController+<>c__DisplayClass1).searchText)) || <>h__TransparentIdentifier0.p.UnitCode.Contains(value(Eurofysica.BusinessLogic.BLL.Controllers.UmbracoProductController+<>c__DisplayClass1).searchText))).Select(<>h__TransparentIdentifier0 => new UmbracoProductOverview() {UmbracoProductId = <>h__TransparentIdentifier0.up.UmbracoProductId, ProductName = <>h__TransparentIdentifier0.up.ProductName, ProductCode = <>h__TransparentIdentifier0.up.ProductCode}).OrderBy( => .ProductName).Count() Now this is how the queries look like that are send to sql server: Select query: Query: SELECT [LPA_L2].[umbracoProductId] AS [UmbracoProductId], [LPA_L2].[productName] AS [ProductName], [LPA_L2].[productCode] AS [ProductCode] FROM ( [eurofysica].[dbo].[umbracoProduct] [LPA_L2] INNER JOIN [eurofysica].[dbo].[product] [LPA_L3] ON [LPA_L2].[umbracoProductId] = [LPA_L3].[umbracoProductId]) WHERE ( ( ( ( ( ( ( ( [LPA_L2].[productCode] LIKE @ProductCode1) OR ( [LPA_L2].[productName] LIKE @ProductName2)) OR ( [LPA_L3].[code] LIKE @Code3)) OR ( [LPA_L3].[description] LIKE @Description4)) OR ( [LPA_L3].[descriptionLong] LIKE @DescriptionLong5)) OR ( [LPA_L3].[unitCode] LIKE @UnitCode6)))) Parameter: @ProductCode1 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @ProductName2 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @Code3 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @Description4 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @DescriptionLong5 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @UnitCode6 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Count query: Query: SELECT TOP 1 COUNT(*) AS [LPAV_] FROM (SELECT [LPA_L2].[umbracoProductId] AS [UmbracoProductId], [LPA_L2].[productName] AS [ProductName], [LPA_L2].[productCode] AS [ProductCode] FROM ( [eurofysica].[dbo].[umbracoProduct] [LPA_L2] INNER JOIN [eurofysica].[dbo].[product] [LPA_L3] ON [LPA_L2].[umbracoProductId] = [LPA_L3].[umbracoProductId]) WHERE ( ( ( ( ( ( ( ( [LPA_L2].[productCode] LIKE @ProductCode1) OR ( [LPA_L2].[productName] LIKE @ProductName2)) OR ( [LPA_L3].[code] LIKE @Code3)) OR ( [LPA_L3].[description] LIKE @Description4)) OR ( [LPA_L3].[descriptionLong] LIKE @DescriptionLong5)) OR ( [LPA_L3].[unitCode] LIKE @UnitCode6))))) [LPA_L1] Parameter: @ProductCode1 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @ProductName2 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @Code3 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @Description4 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @DescriptionLong5 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". Parameter: @UnitCode6 : String. Length: 2. Precision: 0. Scale: 0. Direction: Input. Value: "%%". As you can see no sorting or paging is done (like in my Stored Procedure). This is probably done inside the code after all the results are fetched. This costs a lot of performance! Does anybody know how I can convert my Stored Procedure to Linq to LLBLGen the proper way?

    Read the article

  • Date problem in MYSQL Query

    - by davykiash
    Am looking for a query to sum values in a particular time duration say an year or a particular month in an year using MYSQL syntax.Note that my transaction_date column stores daily amount transacted. Am example of a query that returns total sales in an year query would look something like this SELECT SUM(transaction_amount) WHERE transaction_date = (YEAR) Am example of a query that returns total sales in an particular month and year would look something like this SELECT SUM(transaction_amount) WHERE transaction_date = (YEAR)(MONTH) How achievable is this?

    Read the article

  • What is the maximum length of a C# string [closed]

    - by Ahmet Altun
    Possible Duplicate: What is the maximum possible length of a .NET string? How long a C# string can be in maximum? Is there any limitation? Considering if MSN was written in C#, the instant messaging would be designed as Textbox. So, the content would be Textbox.text, which is a string. But can System.string can store such a long value. I assume, string class holds value contiguously.

    Read the article

  • iPhone SDK - Comparing characters in string

    - by Karl Daniel
    Basically what I'm trying to do is compare 2 strings one from a plist and one from the user's input. I use a while loop to step through each character and compare it and if true then I increase an integer then once the loop has finished I work out the percentage correct / similarity of the plist answer and the user's answer. I seem to be having a problem however as the only return I'm getting is 0. Below is the code I'm using... The code below is all functioning and the question no longer requires answering... Working code... answerLength = boxAnswer.length; //Gets number of characters of first string. plistLength = plistAnswer.length; //Gets number of characters of second string. characterRange = 0; //Sets the variable for which character to look at. charactersCorrect = 0; //Sets the variable of number of matching characters. unichar answerCharacter; //Declares a unichar for the first string. unichar plistCharacter; //Declares a unichar for the second string. while (answerLength > 0 && plistLength > 0) { answerCharacter = [boxAnswer characterAtIndex:characterRange]; //Gets character of first string at the index of the range integer. plistCharacter = [plistAnswer characterAtIndex:characterRange]; //Gets character of second string at the index of the range integer. answerLength--; //Reduces number of characters left to compare. plistLength--; characterRange++; //Increases integer to tell it to look at next character in string. if (answerCharacter == plistCharacter) { //Checks to see if character of first string and character of second string match. charactersCorrect++; //If true increases the number correct. } } //Works out percentage of matching characters out of the total string. totalChar = plistAnswer.length; totalPercentage = (charactersCorrect/totalChar)*100; percentageCorrect.text = [NSString stringWithFormat:@"%i%%",totalPercentage]; Variable Declarations... int answerLength; int plistLength; int characterRange; double totalChar; double charactersCorrect; int totalPercentage;

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >