﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-宝杉的博客-最新评论</title><link>http://www.cppblog.com/robinson119/CommentsRSS.aspx</link><description>UNIX/LINUX;ACE;SNMP;C++</description><language>zh-cn</language><pubDate>Fri, 06 Nov 2009 01:41:00 GMT</pubDate><lastBuildDate>Fri, 06 Nov 2009 01:41:00 GMT</lastBuildDate><generator>cnblogs</generator><item><title>re: CString,string,char*之间的转换</title><link>http://www.cppblog.com/robinson119/archive/2009/11/23/22870.html#101681</link><dc:creator>liubaosen</dc:creator><author>liubaosen</author><pubDate>Mon, 23 Nov 2009 01:58:00 GMT</pubDate><guid>http://www.cppblog.com/robinson119/archive/2009/11/23/22870.html#101681</guid><description><![CDATA[很好很好<img src ="http://www.cppblog.com/robinson119/aggbug/101681.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/robinson119/" target="_blank">liubaosen</a> 2009-11-23 09:58 <a href="http://www.cppblog.com/robinson119/archive/2009/11/23/22870.html#101681#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: CString,string,char*之间的转换</title><link>http://www.cppblog.com/robinson119/archive/2009/11/06/22870.html#100271</link><dc:creator>溪流</dc:creator><author>溪流</author><pubDate>Fri, 06 Nov 2009 01:41:00 GMT</pubDate><guid>http://www.cppblog.com/robinson119/archive/2009/11/06/22870.html#100271</guid><description><![CDATA[<div style="COLOR: #0000ff">LZ 也没有搞得很清楚么。。。</div><br><div style="COLOR: #0000ff">另外，CString 可能是 CStringW/CStringA，在与 string 转换时，如果是 CStringW，还涉及编码转换问题。下面以 CStringA 来说明。</div><br><div>&nbsp;</div><br><div>1 string to CString&nbsp;&nbsp; </div><br><div>&nbsp; CString.format("%s",string.c_str()); </div><br><div>&nbsp;</div><br><div>CStringA = string.c_str() 就可以了</div><br><div>&nbsp;</div><br><div>2 CString to string</div><br><div>string str(CString.GetBuffer(str.GetLength()));</div><br><div>&nbsp;</div><br><div style="COLOR: #0000ff">GetBuffer 有参数的话，可能导致内部的分配空间动作，要进行后续 ReleaseBuffer 操作。</div><br><div><br><div style="COLOR: #0000ff">string = CStringA</div><br><div><br><div><span style="COLOR: #0000ff">string = CStringA.GetBuffer();</span></div><br><div>&nbsp;</div><br></div><br></div><br><div>3 string to char *</div><br><div>char *p=string.c_str();</div><br><div>4 char * to string</div><br><div>string str(char*);</div><br><div>5 CString to char *</div><br><div>strcpy(char <span style="COLOR: #0000ff">*</span>,CString<strike>,sizeof(char)</strike>);</div><br><div style="COLOR: #0000ff">按照 3 风格，这里应该 char *&nbsp; = CStringA; 或者 char *p = CStringA.GetBuffer();</div><br><div>&nbsp;</div><br><div>6 char * to CString</div><br><div><span style="COLOR: #0000ff">CStringA = char * 就可以了</span></div><br><div>&nbsp;</div><br><img src ="http://www.cppblog.com/robinson119/aggbug/100271.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/robinson119/" target="_blank">溪流</a> 2009-11-06 09:41 <a href="http://www.cppblog.com/robinson119/archive/2009/11/06/22870.html#100271#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: CString,string,char*之间的转换</title><link>http://www.cppblog.com/robinson119/archive/2009/11/05/22870.html#100233</link><dc:creator>iccolor</dc:creator><author>iccolor</author><pubDate>Thu, 05 Nov 2009 09:10:00 GMT</pubDate><guid>http://www.cppblog.com/robinson119/archive/2009/11/05/22870.html#100233</guid><description><![CDATA[char *p=string.c_str();<br>这个很好使，关键是你要加入库文件头。<img src ="http://www.cppblog.com/robinson119/aggbug/100233.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/robinson119/" target="_blank">iccolor</a> 2009-11-05 17:10 <a href="http://www.cppblog.com/robinson119/archive/2009/11/05/22870.html#100233#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: example1</title><link>http://www.cppblog.com/robinson119/archive/2009/08/24/30436.html#94227</link><dc:creator>提交失败后,可以通过“恢复上次提交”恢复刚刚提交的内容</dc:creator><author>提交失败后,可以通过“恢复上次提交”恢复刚刚提交的内容</author><pubDate>Mon, 24 Aug 2009 02:37:00 GMT</pubDate><guid>http://www.cppblog.com/robinson119/archive/2009/08/24/30436.html#94227</guid><description><![CDATA[fatal error C1083: Cannot open include file: 'otlv4.h': No such file or directory<img src ="http://www.cppblog.com/robinson119/aggbug/94227.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/robinson119/" target="_blank">提交失败后,可以通过“恢复上次提交”恢复刚刚提交的内容</a> 2009-08-24 10:37 <a href="http://www.cppblog.com/robinson119/archive/2009/08/24/30436.html#94227#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: example1</title><link>http://www.cppblog.com/robinson119/archive/2009/08/24/30436.html#94226</link><dc:creator>提交失败后,可以通过“恢复上次提交”恢复刚刚提交的内容</dc:creator><author>提交失败后,可以通过“恢复上次提交”恢复刚刚提交的内容</author><pubDate>Mon, 24 Aug 2009 02:36:00 GMT</pubDate><guid>http://www.cppblog.com/robinson119/archive/2009/08/24/30436.html#94226</guid><description><![CDATA[提交失败后,可以通过“恢复上次提交”恢复刚刚提交的内容<img src ="http://www.cppblog.com/robinson119/aggbug/94226.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/robinson119/" target="_blank">提交失败后,可以通过“恢复上次提交”恢复刚刚提交的内容</a> 2009-08-24 10:36 <a href="http://www.cppblog.com/robinson119/archive/2009/08/24/30436.html#94226#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: CString,string,char*之间的转换</title><link>http://www.cppblog.com/robinson119/archive/2008/10/22/22870.html#64704</link><dc:creator>aliao</dc:creator><author>aliao</author><pubDate>Wed, 22 Oct 2008 08:26:00 GMT</pubDate><guid>http://www.cppblog.com/robinson119/archive/2008/10/22/22870.html#64704</guid><description><![CDATA[5 CString to char *<br><br>strcpy(char,CString,sizeof(char)); 这里的参数是不是写借了？<br><img src ="http://www.cppblog.com/robinson119/aggbug/64704.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/robinson119/" target="_blank">aliao</a> 2008-10-22 16:26 <a href="http://www.cppblog.com/robinson119/archive/2008/10/22/22870.html#64704#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: OTL 4.0, OTL concept</title><link>http://www.cppblog.com/robinson119/archive/2008/10/14/30435.html#63979</link><dc:creator>xiao_xiao</dc:creator><author>xiao_xiao</author><pubDate>Tue, 14 Oct 2008 11:18:00 GMT</pubDate><guid>http://www.cppblog.com/robinson119/archive/2008/10/14/30435.html#63979</guid><description><![CDATA[我在用到otl_stream时候，我是在流里不断的输入，但是如果其中的一条语句错误，异常了，他是否会把缓存里面的所有清空刷新呢？ 我怀疑这样我入库的时候，会少数据呢？ 联系我 165621600<img src ="http://www.cppblog.com/robinson119/aggbug/63979.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/robinson119/" target="_blank">xiao_xiao</a> 2008-10-14 19:18 <a href="http://www.cppblog.com/robinson119/archive/2008/10/14/30435.html#63979#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: OTL 4.0, OTL concept</title><link>http://www.cppblog.com/robinson119/archive/2008/08/06/30435.html#58141</link><dc:creator>harvey</dc:creator><author>harvey</author><pubDate>Wed, 06 Aug 2008 06:28:00 GMT</pubDate><guid>http://www.cppblog.com/robinson119/archive/2008/08/06/30435.html#58141</guid><description><![CDATA[这个是ＯＴＬ调sql, ODBC的，注意是<br>#define OTL_ODBC <br><br>而不是ＯＲＡＣＬＥ的例子<br><br>因为otl + oracle的例子网上非常多，<br>而otl + sqlServer的例子网上很少，<br><br>在这希望能起到抛砖引玉的作用。<img src ="http://www.cppblog.com/robinson119/aggbug/58141.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/robinson119/" target="_blank">harvey</a> 2008-08-06 14:28 <a href="http://www.cppblog.com/robinson119/archive/2008/08/06/30435.html#58141#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: OTL 4.0, OTL concept</title><link>http://www.cppblog.com/robinson119/archive/2008/08/06/30435.html#58140</link><dc:creator>harvey</dc:creator><author>harvey</author><pubDate>Wed, 06 Aug 2008 06:25:00 GMT</pubDate><guid>http://www.cppblog.com/robinson119/archive/2008/08/06/30435.html#58140</guid><description><![CDATA[忘了对以上例子的说明了。<br><br>以上是OTL中调用存储过程，得到出参的例子，ＯＴＬ说明书里是有的，但我也找了很久才找到的。网址是　<a target="_new" href="http://otl.sourceforge.net/otl3_ex24.htm">http://otl.sourceforge.net/otl3_ex24.htm</a><br><br>需要注意以下<br> otl_stream o(1, stored procedure call  <br>            &quot;{call my_proc(&quot;              <br>　　　　　　　&quot; :A&lt;int,inout&gt;, &quot;          //<br>　　　　　　　&quot; :B&lt;char[31],out&gt;, &quot;    //    <br>　　　　　　 　&quot; :C&lt;char[31],in&gt; &quot;      //char[31], 和in之间不能有空格<br>　　　　　　　&quot;)}&quot;,                <br>　　　　　　　db);<br><img src ="http://www.cppblog.com/robinson119/aggbug/58140.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/robinson119/" target="_blank">harvey</a> 2008-08-06 14:25 <a href="http://www.cppblog.com/robinson119/archive/2008/08/06/30435.html#58140#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: OTL 4.0, OTL concept</title><link>http://www.cppblog.com/robinson119/archive/2008/08/06/30435.html#58139</link><dc:creator>harvey</dc:creator><author>harvey</author><pubDate>Wed, 06 Aug 2008 06:20:00 GMT</pubDate><guid>http://www.cppblog.com/robinson119/archive/2008/08/06/30435.html#58139</guid><description><![CDATA[This example demonstrates a stored procedure call.<br><br>Source Code<br>#include &lt;iostream&gt;using namespace std;#include &lt;stdio.h&gt;#define OTL_ODBC_MSSQL_2005 // Compile OTL 4/ODBC, MS SQL 2005//#define OTL_ODBC // Compile OTL 4/ODBC. Uncomment this when used with MS SQL 7.0/ 2000#include &lt;otlv4.h&gt;otl_connect db; // connect objectvoid stored_proc(void)// invoking stored procedure{  otl_stream o(1, // buffer size should be equal to 1 in case of stored procedure call              &quot;{call my_proc(&quot;              &quot; :A&lt;int,inout&gt;, &quot;              &quot; :B&lt;char[31],out&gt;, &quot;              &quot; :C&lt;char[31],in&gt; &quot;              &quot;)}&quot;,                 // stored procedure call              db // connect object             ); o.set_commit(0); // set stream auto-commit off since                  // the stream does not generate transaction o&lt;&lt;1&lt;&lt;&quot;Test String1&quot;; // assigning :1 = 1, :3 = &quot;Test String1&quot; int a; char b[31]; o&gt;&gt;a&gt;&gt;b; cout&lt;&lt;&quot;A=&quot;&lt;&lt;a&lt;&lt;&quot;, B=&quot;&lt;&lt;b&lt;&lt;endl;}int main(){ otl_connect::otl_initialize(); // initialize ODBC environment try{  db.rlogon(&quot;uid=scott;pwd=tiger;dsn=mssql&quot;); // connect to ODBC  otl_cursor::direct_exec   (db,    &quot;CREATE PROCEDURE my_proc &quot;    &quot;  @A int out, &quot;    &quot;  @B varchar(60) out, &quot;    &quot;  @C varchar(60) &quot;    &quot;AS &quot;    &quot;BEGIN &quot;    &quot;  SELECT @A=@A+1&quot;    &quot;  SELECT @B=@C &quot;    &quot;END&quot;   );  // create stored procedure  stored_proc(); // invoking stored procedure } catch(otl_exception&amp; p){ // intercept OTL exceptions  cerr&lt;&lt;p.msg&lt;&lt;endl; // print out error message  cerr&lt;&lt;p.code&lt;&lt;endl; // print out error code  cerr&lt;&lt;p.var_info&lt;&lt;endl; // print out the variable that caused the error  cerr&lt;&lt;p.sqlstate&lt;&lt;endl; // print out SQLSTATE message  cerr&lt;&lt;p.stm_text&lt;&lt;endl; // print out SQL that caused the error } db.logoff(); // disconnect from the data source return 0;} <br>Output<br> A=2, B=Test String1<br><img src ="http://www.cppblog.com/robinson119/aggbug/58139.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/robinson119/" target="_blank">harvey</a> 2008-08-06 14:20 <a href="http://www.cppblog.com/robinson119/archive/2008/08/06/30435.html#58139#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>