小问题(马上给分) 应该怎么给List Control里面写数据啊为什么我只能写一列啊再就是能不能给利用ADO连接SQLSEVER的代码啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 要首先用InsertItem插入一行,然后在用SetItemText再插哪一列的数据 HRESULT hr; _ConnectionPtr m_pConnTemp = theApp.m_pConnection; UpdateData(); CString strConnection="Provider=SQLOLEDB.1;Data Source=127.0.0.1;Initial Catalog=zviewrecord;User ID=sa;PWD=123"; try { hr = m_pConnTemp.CreateInstance("ADODB.Connection"); if(SUCCEEDED(hr)) { hr=m_pConnTemp->Open((_bstr_t)strConnection,"","",-1); AfxMessageBox("Sucess!"); } } catch(_com_error e) { m_pan=false; GetDlgItem(IDC_InsertDataBase)->EnableWindow(false); CCommon common; AfxMessageBox(common.DisplayAdoError(m_pConnTemp)); } if (m_pConnTemp != NULL) { if (m_pConnTemp->State) { if (theApp.m_pConnection != NULL) { if (theApp.m_pConnection->State) { theApp.m_pConnection->Close (); } } theApp.m_pConnection = m_pConnTemp; } }127.0.0.1是连接本地的sql sever,用户名是sa,密码是:123,zviewrecord是初始的库名若连其他的机子就用他的IP 好了 使用顺序: SetExtendedStyle( DWORD dwNewStyle );设置风格 InsertColumn( int nCol, const LVCOLUMN* pColumn );插入列 InsertItem( int nItem, LPCTSTR lpszItem, int nImage );插入行和设置第一列内容 SetItemText( int nItem, int nSubItem, LPTSTR lpszText );设置后面列的内容 DeleteItem( int nItem ); 或 DeleteAllItems( );删除行 DeleteColumn( int nCol );删除列函数使用详见msdn VC用到摄像头跟串口,得学哪些? 微软mfc调试器是不是不准啊! 获取打印任务的页数不正确。 棘手:关于CRichEdit2 的Dual-Font问题,如何设置英文字的字体?或者如何让所有英文字母都采用缺省的字体? 请问如何用ado对excel进行操作? 如何编程启动XP/2000中的的网络“新建连接”向导?(----一定给分!----) 如何带参数实例化一个Com对象? 考你还给你加分,char abc[4]显示在编辑框中 慢者如斯夫! 怎样更改 VC程序项目名 ? SDI结构中使用多个视图,怎样让不同的视图使用不同的工具栏和菜单? 在officeXP中添加com组件??
HRESULT hr;
_ConnectionPtr m_pConnTemp = theApp.m_pConnection; UpdateData();
CString strConnection="Provider=SQLOLEDB.1;Data Source=127.0.0.1;Initial Catalog=zviewrecord;User ID=sa;PWD=123";
try
{
hr = m_pConnTemp.CreateInstance("ADODB.Connection"); if(SUCCEEDED(hr))
{
hr=m_pConnTemp->Open((_bstr_t)strConnection,"","",-1);
AfxMessageBox("Sucess!");
}
}
catch(_com_error e)
{
m_pan=false;
GetDlgItem(IDC_InsertDataBase)->EnableWindow(false);
CCommon common;
AfxMessageBox(common.DisplayAdoError(m_pConnTemp));
}
if (m_pConnTemp != NULL)
{
if (m_pConnTemp->State)
{
if (theApp.m_pConnection != NULL)
{
if (theApp.m_pConnection->State)
{
theApp.m_pConnection->Close ();
}
}
theApp.m_pConnection = m_pConnTemp;
}
}
127.0.0.1是连接本地的sql sever,用户名是sa,密码是:123,zviewrecord是初始的库名
若连其他的机子就用他的IP 好了
SetExtendedStyle( DWORD dwNewStyle );设置风格
InsertColumn( int nCol, const LVCOLUMN* pColumn );插入列
InsertItem( int nItem, LPCTSTR lpszItem, int nImage );插入行和设置第一列内容
SetItemText( int nItem, int nSubItem, LPTSTR lpszText );设置后面列的内容
DeleteItem( int nItem ); 或 DeleteAllItems( );删除行
DeleteColumn( int nCol );删除列函数使用详见msdn