<<<<<<<<===在VC里ADO中Stream对象的Open方法如何使用???===>>>>>>>>>
能找到的例子都是vb的,在vb中可以不加参数,但是VC中就不行,谁有这方面的经验请
赐教!!!
每次编译可以通过,但是运行到open这一句就出错
代码如下
_bstr_t SQLxml;
try
{
m_connection.CreateInstance("ADODB.Connection");
m_command.CreateInstance("ADODB.Command");
m_strmIn.CreateInstance("ADODB.Stream");
m_strmOut.CreateInstance("ADODB.Stream");
m_recordset.CreateInstance("ADODB.Recordset");
m_record.CreateInstance("ADODB.Record");
//Open a conneciton to the SQL Server
//m_connection->Provider="SQLOLEDB";
_bstr_t sql;
sql="driver=sql server;server=yangys;database=test;uid=sa";
m_connection->Open(sql,"","",adModeUnknown);
m_command->ActiveConnection=m_connection;
//build the command string for a XML
SQLxml="<root xmlns:sql=""urn:schemas-microsoft-com:xml-sql""><sql:query><![CDATA[select * form employee for xml auto]]></sql:query></root>";
//Open the command stream and write our template to it
_bstr_t bstrUser="sa";
_bstr_t bstrPwd="";
m_strmIn->GetState(); // for test state
m_strmIn->Open //<<<<<< RUNTIME ERROR>>>>>>>("",adModeUnknown,adOpenStreamFromRecord,bstrUser,bstrPwd);
m_strmIn->WriteText(SQLxml,adWriteChar);
m_strmIn->Position=0;
//Execute the command,open the return stream,and read the result
m_strmOut->Open("",adModeUnknown,adOpenStreamAsync,"","");
m_strmOut->LineSeparator=adCRLF;
_variant_t rsAffect;
Properties* pProperties;
Property* pProperty;
_variant_t vtIndex;
vtIndex.vt=VT_I2;
m_command->get_Properties((Properties**)&pProperties);
pProperties->get_Item(vtIndex,(Property**)&pProperty);
pProperty->GetValue();
m_command->Execute(&rsAffect,NULL,adExecuteStream);
m_strmOut->Position=0;
运行到m_strmIn->Open这句时就会出错,是内存读取错误
请帮忙看看,谢谢!