您的当前位置:我要购书网>在线阅读>VC++/C#/C

使用vc6进行ado编程,使用sql server 2000+windows server 2003+vc6

来源:互联网  作者:我要购书网信息中心  发布:我要购物网收集整理  发布时间:2006-8-31 人气:194

使用VC6进行ADO编程,使用SQL SERVER 2000+WINDOWS SERVER 2003+VC6

目的是将SERVER产生的日志文件--文本格式,写入到SQL SERVER数据库,实现功能为:
1.修改源日志格式为以跳格键分割字段,字段用引号引起,写入成一个新的日志文件。
2.程序读出新日志文件,写入到数据库。

由于是初学VC,不当之处请高人指正,万分感谢!

第一部分

工程名称为vcado,如下是在vcado.cpp中的重要源代码:此代码目的为打开Connection对象!

BOOL CVcadoApp::InitInstance()
{
AfxEnableControlContainer();
AfxOleInit();///初始化COM库
////////////连接数据库//////////////
HRESULT hr;
try
{
hr = m_pConnection.CreateInstance("ADODB.Connection");///创建Connection对象
if(SUCCEEDED(hr))
{
hr = m_pConnection->Open("DSN=test;UID=;PWD=;","","",adModeUnknown);///连接数据库
}
}
}
catch(_com_error e)///捕捉异常
{
CString errormessage;
errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage());
AfxMessageBox(errormessage);///显示错误信息
return FALSE;
}
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.

#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif

CVcadoDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}

// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
int CVcadoApp::ExitInstance()
{
if(m_pConnection->State)
m_pConnection->Close(); ///如果已经打开了连接则关闭它
return CWinApp::ExitInstance();}由于本人上网时间问题,下次进行发表“第二部分”。

相关文章
· 使用 system.web.mail发送邮件
· 使用delphi开发多媒体播放音轨问题的faq(原创)
· 使用directshow播放摄像头的基类
· 使用dumpbin命令
· 使用mouse_event来模拟一次选中文本框中的文本
· 使用eclipse进行swt编程(2)
· 使用md5校验和算法保护文件
· 使用directshow播放mpeg的基类
· 使用vc6进行ado编程,使用sql server 20..
· 使用vc++进行tray区编程
热点文章
%>
· creating user controls
· 提高fastreplace速度 (fstrrep.pas)
· asc ii 完整码表及简介
· 自动生成拼音(汉字反查到拼音)
· sql2000无法安装的解决办法
· 浏览器集成教学 自定义浏览器
· vc++技术内幕(第四版)笔记(第7章)
· mysql5.0中文乱码解决方案
· sql server日期计算
· vc下利用ado连接access数据库
 淘宝旺旺:我要购书网上书店『图书目录
本购书中心地址: 杭州市延安路111号清波商厦南楼D座(总部) 上海市闸北区老沪太路网上购书中心(沪部),  邮编:310002
电子邮件:books@51goushu.com  经营许可证编号:沪ICP备06038574号
版权所有 2003-2008 © All Rights Reserved .购书网