就像Oracle 和 MS SQL Server中自带的运行SQL语句,打印运行结果的功能一样
请问有甚么好的方案吗?
有贴点代码更好
不胜感激
请问有甚么好的方案吗?
有贴点代码更好
不胜感激
解决方案 »
- 一个很烦人又很奇怪的问题
- 关于修改注册表
- 有关TreeCtrl控件的叶子节点问题,不吝给分
- 对串口通信事件使用的疑惑
- UDP通过代理或NAT之类进行IP或者Port映射,失效时间为多少?
- 有没有将windows nt的某个用户加入管理员组的其他办法?
- SetROP2(R2_XORPEN)的困扰
- 给定lib文件能否判断是静态库的lib还是动态库的lib
- 文件格式大全formats.myrice.com
- 简单的问题,但非大虾才能搞定.如何去掉CFrameView自动生成的水平,垂直滚动条.我的控件放不到边啊,痛苦啊!
- 为什么我的窗口指针老是传入不了非类函数里?------------------------------------------------------------------?
- 捕获浏览器事件直接造成浏览器阻塞,大家看看咋了?
获得列数,获取行数,用列表控件相应的产生列和行,把数据显示上去就行了。
不过除了需要查询表,还有insert,update,delete,CreateTable, CreateView等操作,怎样写最好呢? 最好能够考虑通用性
程序越小越好,因为要放在远程的肉鸡上运行的, 用 winsocket发送 SQL语句来控制的, 对方是MySQL数据库, WindowXP
不胜感激
{
if (m_strService.IsEmpty())
{
::MessageBox(NULL,"·þÎñÃû²»ÄÜΪ¿Õ","Ìáʾ",MB_OK);
return FALSE;
} theApp.m_pConnection.CreateInstance(__uuidof(Connection));
try
{
//OLEDBÇý¶¯
theApp.m_strDatabase=m_strService;
CString strConn;
strConn="Provider=OraOLEDB.Oracle.1;Password=";
strConn+=m_strPassword;
strConn+=";Persist Security Info=True;User ID=";
strConn+=m_strUsername;
// strConn+=";SERVER=";
// strConn+=m_strService;
strConn+=";Data Source=";
strConn+= m_strService;
theApp.m_pConnection->Open((_bstr_t)strConn,
"",
"",
adModeUnknown);
}
catch(_com_error e)
{
::MessageBox(NULL,e.Description(),"Ìáʾ",MB_OK);
return FALSE;
}
::MessageBox(NULL,"Êý¾Ý¿âÁ¬½Ó³É¹¦£¡","Ìáʾ",MB_OK);
return TRUE;}BOOL CDlgDBConnect::ConnectSQLServer()
{
if (m_strService.IsEmpty())
{
::MessageBox(NULL,"·þÎñÃû²»ÄÜΪ¿Õ","Ìáʾ",MB_OK);
return FALSE;
}
if (m_strDatabase.IsEmpty())
{
::MessageBox(NULL,"Êý¾Ý¿â²»ÄÜΪ¿Õ","Ìáʾ",MB_OK);
return FALSE;
} theApp.m_pConnection.CreateInstance(__uuidof(Connection));
try
{
theApp.m_strDatabase=m_strDatabase; CString strConn;
strConn="Provider=SQLOLEDB.1;Password=";
strConn+=m_strPassword;
strConn+=";Persist Security Info=True;User ID=";
strConn+=m_strUsername;
strConn+=";Initial Catalog=";
strConn+=m_strDatabase;
strConn+=";Data Source=";
strConn+=m_strService;
theApp.m_pConnection->Open((_bstr_t)strConn,
"",
"",
adModeUnknown);
}
catch(_com_error e)
{
::MessageBox(NULL,e.Description(),"Ìáʾ",MB_OK);
return FALSE;
}
::MessageBox(NULL,"Êý¾Ý¿âÁ¬½Ó³É¹¦£¡","Ìáʾ",MB_OK);
return TRUE;}
BOOL CDlgRecordset::QueryRecord()
{
_CommandPtr cmd;
_RecordsetPtr rs;
_ConnectionPtr conn;
_variant_t vra;
VARIANT *vt1 = NULL;
try
{
/* cmd.CreateInstance( __uuidof(Command));
rs.CreateInstance(__uuidof(Recordset));
conn.CreateInstance(__uuidof(Connection));*/ UpdateData(TRUE);
theApp.m_pConnection->PutCursorLocation(adUseClient);
/* conn->CursorLocation = adUseClient;
conn->Open(_bstr_t( theApp.m_pConnection.GetInterfacePtr() ), L"", L"", -1);
cmd->ActiveConnection = conn;
cmd->CommandText = (_bstr_t) m_strQuery;
cmd->CommandType = adCmdText;
rs = cmd->Execute(&vra,vt1, adCmdText);*/
/*rs->PutRefActiveConnection(theApp.m_pConnection);
rs->Open((_bstr_t)m_strQuery,
theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);*/
/// ((CTestDllApp*)(&theApp))->m_pConnection
/// m_pRecordset.CreateInstance(__uuidof(Recordset));
/* m_pRecordset->Open((_bstr_t)m_strQuery,
_variant_t((IDispatch*)theApp.m_pConnection, TRUE),
adOpenStatic,
adLockOptimistic,
adCmdText);*/
if(m_pRecordset->State==1)
{
m_pRecordset->Close();
}
m_pRecordset->Open((_bstr_t)m_strQuery,
theApp.m_pConnection.GetInterfacePtr(),//»ñÈ¡¿â½Ó¿âµÄIDispatchÖ¸Õë
adOpenStatic,
adLockOptimistic,
adCmdText);
/* m_DataGrid.SetRefDataSource(NULL);
m_DataGrid.SetRefDataSource((LPUNKNOWN)m_pRecordset);
m_DataGrid.Refresh();*/
}
catch (_com_error &e)
{
::MessageBox(NULL,e.Description(),"Ìáʾ",MB_OK);
}
{
//用_RecordsetPtr
}
else
{
//用_CommandPtr
}
请问有没有一种通用的方法呢?
不胜感激