㈠ 在VC++中如何从数据库中读取数据和向数据库中写入数据
#include "stdafx.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
ADOConn::ADOConn()
{
}
ADOConn::~ADOConn()
{
}
// 初始化—连接数据库
void ADOConn::OnInitADOConn()
{
// 初始化OLE/COM库环境
::CoInitialize(NULL);
try
{
// 创建Connection对象
m_pConnection.CreateInstance("ADODB.Connection");
// 设置连接字符串,必须是BSTR型或者_bstr_t类型
_bstr_t strConnect = "Provider=MSDASQL.1;Persist Security Info=False;User ID=***;Data Source=***;";
m_pConnection->Open(strConnect,"","",adModeUnknown);
}
// 捕捉异常
catch(_com_error e)
{
// 显示错误信息
AfxMessageBox(e.Description());
}
}
// 执行查询
_RecordsetPtr& ADOConn::GetRecordSet(_bstr_t bstrSQL)
{
try
{
// 连接数据库,如果Connection对象为空,则重新连接数据库
if(m_pConnection==NULL)
OnInitADOConn();
// 创建记录集对象
m_pRecordset.CreateInstance(__uuidof(Recordset));
// 取得表中的记录
m_pRecordset->Open(bstrSQL,m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
}
// 捕捉异常
catch(_com_error e)
{
// 显示错误信息
AfxMessageBox(e.Description());
}
// 返回记录集
return m_pRecordset;
}
// 执行SQL语句,Insert Update _variant_t
BOOL ADOConn::ExecuteSQL(_bstr_t bstrSQL)
{
// _variant_t RecordsAffected;
try
{
// 是否已经连接数据库
if(m_pConnection == NULL)
OnInitADOConn();
// Connection对象的Execute方法:(_bstr_t CommandText,
// VARIANT * RecordsAffected, long Options )
// 其中CommandText是命令字串,通常是SQL命令。
// 参数RecordsAffected是操作完成后所影响的行数,
// 参数Options表示CommandText的类型:adCmdText-文本命令;adCmdTable-表名
// adCmdProc-存储过程;adCmdUnknown-未知
m_pConnection->Execute(bstrSQL,NULL,adCmdText);
return true;
}
catch(_com_error e)
{
AfxMessageBox(e.Description());
return false;
}
}
void ADOConn::ExitConnect()
{
// 关闭记录集和连接
if (m_pRecordset != NULL)
m_pRecordset->Close();
m_pConnection->Close();
// 释放环境
::CoUninitialize();
}
㈡ 求助!!!紧急!用VC或者LABVIEW编写读取串口数据的程序
按照你的描述,我的理解是
大方向是先用LabVIEW创建个project,然后新建个VI做个面板,再然后把VI封装成dll。
最后在vc代码中调用。
大体上就是这个思路。
㈢ 想编写股票自动交易软件,读取通达信行情数据,操纵券商交易软件自动下单,学什么编程语言好呢
要自己实现一款能够自动盯盘、自动成交的软件是不现实的,没有Window底层的编程经验,不了解Windows底层机制是不可能完成的,Window底层的编程主要用VC,现在已经有很多类似的软件,比如金牛盯盘、金鹰股票自动交易软件等,都很不错,如果论使用简单和方便,金鹰股票自动交易软件应该是很不错的
㈣ 怎么用c++写股票管理软件的代码
这位大哥的问题可挺复杂,不是几句话可以说请的,不是几行代码能解释的。
㈤ 股票软件运行时打开的数据文件,如何使用vc6同时打开数据文件
共享存取,
股票软件一般都有自己的格式,除非你知道格式,否则打开也没用
㈥ 怎样用excel 实时读取 股票日线数据
定量分析的第一步,是获取数据。
获取股票历史行情数据最方便的途径,就是直接读取股票行情软件留在你电脑中的日线数据文件。
但如果不是程序员,电脑里一般不会有VB、VC之类的编程语言。
其实,大家的电脑中一般都有OFFICE。OFFICE中的EXCEL自带了一个VBA语言的编程环境。功能也很强大。
我用EXCEL里的VBA编写了一段代码,读取通达信股票行情软件的日线文件。已经测试通过。
代码如下。与爱好定量分析的朋友分享。
TypeMyType
a1AsLong'标示码
a2AsLong'日期
a3AsSingle'开盘价
a4AsSingle'最高价
a5AsSingle'最低价
a6AsSingle'收盘价
a7AsSingle'成交金额
a8AsLong'成交量
EndType
Sub按钮1_Click()
DimFile2AsInteger
DimbAsMyType
File1=FreeFile
Opensh600000.dayForBinaryAccessReadAs#File1i=1DoWhileNotEOF(File1)
Get#File1,,b
Cells(i,1)=b.a1
Cells(i,2)=b.a2
Cells(i,3)=b.a3
Cells(i,4)=b.a4
Cells(i,5)=b.a5
Cells(i,6)=b.a6
㈦ VC++中 文件中数据的读取
建议你参考我写的一段代码
void CMainFrame::planeOutput()
{
for (int i=0;i<PictSum;i++)
{
printf("%f %f %d\n",xPos[i],zPos[i],statusArray[i]);
}
printf("\nConfirm Plane Data to Write to File...\n");
CString xpos,zpos,status,str;
CFileDialog fileDlg(FALSE,"txt", "PlaneData.txt", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "bitmap file (*.txt) |*.txt| |");
CFile file;
if (fileDlg.DoModal()==IDOK)
{
file.Open(fileDlg.GetPathName(),CFile::modeCreate|CFile::modeWrite);
for (int i=0;i<PictSum;i++)
{
/*time.Format("%f",timeArray[i]);
acc.Format("%f",accArray[i]);
status.Format("%d",statusArray[i]);
str=time+" "+acc+" "+status;*/
xpos.Format("%f",xPos[i]);
zpos.Format("%f",zPos[i]);
status.Format("%d",statusArray[i]);
str=xpos+" "+zpos+" "+status;
file.Write(str,str.GetLength());
file.Write(_T("\r\n"),2);
}
file.Close();
}
}
㈧ 如何用C程序实现 读取DAT股票文件数据
int a = 0x19554c32;
这样就能拿到数据,但读文件的时要二进制打开读,就是fopen("数据文件名“,"rb");
然后fread读,都到一个buf里,让后将buf按照你的类型强转就行。
㈨ VC关于读取一个程序的内存数据
兄弟,你的szBuffer是个int型的数组哦,printf("%d\n",szBuffer[0])应该就可以了
㈩ 我用VC++编写了一个数据传输的程序,想把接受到的数据自动保存到SQL数据库,想请教怎么做
用线程啊,定时判断是否有新数据进来,有新数据则保存,没新数据,继续休眠,等待下次判断