代码如下:
_CatalogPtr m_pCatalog = NULL;
_ConnectionPtr m_pConnection = NULL;
try
{
m_pConnection.CreateInstance(__uuidof(Connection));
m_pConnection->Open("Driver=SQL Server;Database=TestDB;Server=XSERVER;UID=VIP;PWD=;","","",NULL);
m_pCatalog.CreateInstance(__uuidof(Catalog));
m_pCatalog->PutActiveConnection(variant_t((IDispatch *) m_pConnection));
m_pCatalog->Tables->Delete("TestTable"); }
catch(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
printf("\n\tSource : %s \n\tdescription : %s \n ",
(LPCSTR)bstrSource,(LPCSTR)bstrDescription);
}
_CatalogPtr m_pCatalog = NULL;
_ConnectionPtr m_pConnection = NULL;
try
{
m_pConnection.CreateInstance(__uuidof(Connection));
m_pConnection->Open("Driver=SQL Server;Database=TestDB;Server=XSERVER;UID=VIP;PWD=;","","",NULL);
m_pCatalog.CreateInstance(__uuidof(Catalog));
m_pCatalog->PutActiveConnection(variant_t((IDispatch *) m_pConnection));
m_pCatalog->Tables->Delete("TestTable"); }
catch(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
printf("\n\tSource : %s \n\tdescription : %s \n ",
(LPCSTR)bstrSource,(LPCSTR)bstrDescription);
}
解决方案 »
- BITMAP bmWidthBytes 计算方法
- 请问这是属于什么控件
- 有做三菱上位机的请进来看看
- clistbox
- "cannot access the class view information file, class view information file will not be available"打开工程就是这样!这是为什么?
- 关于在列表框中处理键盘的PgDn和PgUp的问题
- 哪里有ULtimate toolbox和ultimate grid?免费的。
- windows的消息队列的工作原理
- 有没有谁解析过*.pst文件,怎么得到其中的对象?谢谢
- 怎样去掉ToolBar上面的那条横线??????????????? 50分!!!!!!! 高分求解!
- Richedit 中关于streamin 和 streamout 的问题
- 选择目录的对话框怎么指定初始目录??
我也搞不懂为何m_pCatalog->Tables->Delete("TestTable");不成功
反正能达到目的就行.
{
BOOL bResult;
HRESULT hr;
CString strConn;#ifdef JETDB_ACCESS
// CString str=JETDB_MDBFILE;
strConn.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s",
m_strDatabase);
/*
strConn.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;User ID=%s;PWD=%s",
m_strDatabase,
m_strUser,
m_strPassword);
*/
#else // SQL SERVER
strConn.Format("Provider=SQLOLEDB;Password=%s;Persist Security Info=True;User ID=%s;Initial Catalog=%s;Data Source=%s",
m_strPassword,
m_strUser,
m_strDatabase,
m_strServer);
#endif if((m_pConnection!=NULL)&&(m_pConnection->State))
{
m_pConnection->Close();
//m_pConnection->Release();
}
//m_pConnection=NULL; bResult = FALSE;
try
{
hr = m_pConnection.CreateInstance(__uuidof(Connection));
if(SUCCEEDED(hr))
{
hr = m_pConnection->Open(_bstr_t(strConn),"","",-1);
if(SUCCEEDED(hr))
{
bResult = TRUE;
}
else
{
if(m_pConnection->State)
{
m_pConnection->Close();
//m_pConnection->Release();
}
//m_pConnection = NULL;
}
}
else
{
//m_pConnection = NULL;
}
}
catch(_com_error e)
{
} return bResult;
}
一个是delete from table (where ...)
一个是delete * from table (where ...)
不知道是否这个原因?