⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_62914.htm

📁 vc
💻 HTM
字号:
<p>
序号:62914 发表者:AJ 发表日期:2003-11-29 20:00:50
<br>主题:怎么把CString类型转换为Variant类型???????
<br>内容:怎么把CString类型转换为Variant类型???????
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:dstwwx 回复日期:2003-11-29 20:14:14
<br>内容:Variant 没有啊。<BR>是 _variant_t 吗?<BR><BR>应该可以直接赋值。<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;CString test=&#34;this is a test&#34;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;_variant_t x;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x=test;<BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:AJ 回复日期:2003-11-29 20:23:24
<br>内容:对!是_variant_t!!!<BR>_RecordsetPtr m_pDlgRecordset;<BR>&nbsp;&nbsp;&nbsp;&nbsp;CString sql;<BR>&nbsp;&nbsp;&nbsp;&nbsp;_variant_t x;<BR>&nbsp;&nbsp;&nbsp;&nbsp;x=&#34;adfdasf&#34;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;sql=&#34;select * from info&#34;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;try<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pDlgRecordset.CreateInstance(_T(&#34;ADODB.Recordset&#34;));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pDlgRecordset-&gt;Open((LPTSTR)sql.GetBuffer(130),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_variant_t((IDispatch *)(((CAddressApp*)AfxGetApp())-&gt;m_pConnection),true),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;adOpenDynamic,adLockPessimistic,adCmdText);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pDlgRecordset-&gt;AddNew();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pDlgRecordset-&gt;GetCollect(&#34;name&#34;) = x<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_pDlgRecordset-&gt;Update();<BR><BR>请问怎么样加入数据库里呀??name是一个字段!!!<BR>???????????????????????????????????
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:dstwwx 回复日期:2003-11-29 20:26:09
<br>内容:m_pDlgRecordset-&gt;GetCollect(&#34;name&#34;) = x<BR>代码不正确,这是读的方法。<BR>应该是<BR>m_pRecordset-&gt;PutCollect(&#34;Name&#34;, _variant_t(m_Name));<BR><BR>可以参考下面连接:<BR>http://www.vchelp.net/itbookreview/view_paper.asp?paper_id=554
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:AJ 回复日期:2003-11-29 20:44:32
<br>内容:谢谢!!!<BR>我搞错了!!<BR>哎!!我太差了!!!<BR>VC难能可贵!<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:dstwwx 回复日期:2003-11-29 20:48:20
<br>内容:鼓励一下!<BR><BR>要细心。<BR>高手也是从菜鸟成长起来的。<BR><BR>俺也处于菜的阶段<BR>共同进步!<BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -