这是一个VehQueryDlg的窗口的实现函数,需要实现连接sql数据库,增加或删除其中的某一表中的数据,具体该怎么修改啊?
[code=C/C++][/
// VehQueryDlg.cpp : implementation file
//#include "stdafx.h"
#include "JLDbInterFace.h"
#include "VehQueryDlg.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CVehQueryDlg dialog
CVehQueryDlg::CVehQueryDlg(CWnd* pParent /*=NULL*/)
: CDialog(CVehQueryDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CVehQueryDlg)
m_iChno = -1;
m_sPlate = _T("");
m_iSpeed1 = 0;
m_iSpeed2 = 0;
//}}AFX_DATA_INIT
}
void CVehQueryDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CVehQueryDlg)
DDX_Control(pDX, IDC_LIST3, m_list);
DDX_Control(pDX, IDC_DATETIMEPICKER4, m_dt4);
DDX_Control(pDX, IDC_DATETIMEPICKER3, m_dt3);
DDX_Control(pDX, IDC_DATETIMEPICKER2, m_dt2);
DDX_Control(pDX, IDC_DATETIMEPICKER1, m_dt1);
DDX_Control(pDX, IDC_BUTTON2, m_ShowContainer);
DDX_CBIndex(pDX, IDC_COMBO1, m_iChno);
DDX_Text(pDX, IDC_EDIT1, m_sPlate);
DDX_Text(pDX, IDC_EDIT2, m_iSpeed1);
DDX_Text(pDX, IDC_EDIT3, m_iSpeed2);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CVehQueryDlg, CDialog)
//{{AFX_MSG_MAP(CVehQueryDlg)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST3, OnItemchangedList3)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CVehQueryDlg message handlers//查询数据功能
void CVehQueryDlg::OnButton1() 
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString ls_time1,ls_time2;
CString ls_month,ls_day,ls_hour,ls_minute,ls_second;

//取出时间值
COleDateTime tempTime1,tempTime2;
m_dt1.GetTime(tempTime1);
m_dt2.GetTime(tempTime2); ls_month.Format("%d",100+tempTime1.GetMonth());
ls_month = ls_month.Right(2);
ls_day.Format("%d",100+tempTime1.GetDay());
ls_day = ls_day.Right(2);
ls_hour.Format("%d",100+tempTime2.GetHour());
ls_hour = ls_hour.Right(2);
ls_minute.Format("%d",100+tempTime2.GetMinute());
ls_minute = ls_minute.Right(2);
ls_second.Format("%d",100+tempTime2.GetSecond());
ls_second = ls_second.Right(2); ls_time1.Format("%d-%s-%s %s:%s:%s",tempTime1.GetYear(),ls_month,ls_day,ls_hour,ls_minute,ls_second); m_dt3.GetTime(tempTime1);
m_dt4.GetTime(tempTime2); ls_month.Format("%d",100+tempTime1.GetMonth());
ls_month = ls_month.Right(2);
ls_day.Format("%d",100+tempTime1.GetDay());
ls_day = ls_day.Right(2);
ls_hour.Format("%d",100+tempTime2.GetHour());
ls_hour = ls_hour.Right(2);
ls_minute.Format("%d",100+tempTime2.GetMinute());
ls_minute = ls_minute.Right(2);
ls_second.Format("%d",100+tempTime2.GetSecond());
ls_second = ls_second.Right(2); ls_time2.Format("%d-%s-%s %s:%s:%s",tempTime1.GetYear(),ls_month,ls_day,ls_hour,ls_minute,ls_second); //构建军SQL语句
CString ls_sql,ls_where;
ls_where.Format(" where (JGSJ >= '%s' and JGSJ <= '%s')",ls_time1,ls_time2);
//加入车道条件
if (m_iChno > 0)
{
ls_sql.Format("%s and CDBB = '%d'",ls_where,m_iChno);
ls_where = ls_sql;
}
//加入速度范围
ls_sql.Format("%s and (CLSD >= %d and CLSD <= %d)",ls_where,m_iSpeed1,m_iSpeed2);
ls_where = ls_sql;
//加入车牌号码
if (m_sPlate != "")
{
ls_sql.Format("%s and HPHM = '%s'",ls_where,m_sPlate);
ls_where = ls_sql;
} ls_sql = "Select * from CLTXForm" + ls_where + "order by JGSJ"; m_AddFlag = FALSE; 
//清空列表
m_list.DeleteAllItems();

//查询数据
_RecordsetPtr recodData;
recodData = pMainDlg->m_pConDbObj.GetData(ls_sql);
if (recodData==NULL) 
{
MessageBox("无符合条件记录!");
return ;
}
if (recodData->adoBOF)
{
recodData.Release();
MessageBox("无符合条件记录!");
return ;
}
else
{
recodData->MoveFirst();
_variant_t lv_data;
int li_index = 0;
CString ls_str;
while (!recodData->adoEOF)
{
ls_str.Format("%d",li_index);
li_index = m_list.InsertItem(m_list.GetItemCount(),ls_str);

lv_data = recodData->GetCollect("HPHM");
ls_str = vartostr(&lv_data);
m_list.SetItemText(li_index,1,ls_str); lv_data = recodData->GetCollect("HPYS");
ls_str = vartostr(&lv_data);
m_list.SetItemText(li_index,2,ls_str);

ls_str.Format("%d",long(recodData->GetCollect("CLSD")));
m_list.SetItemText(li_index,3,ls_str); lv_data = recodData->GetCollect("JGSJ");
ls_str = vartostr(&lv_data);
m_list.SetItemText(li_index,4,ls_str); lv_data = recodData->GetCollect("CDBB");
ls_str = vartostr(&lv_data);
m_list.SetItemText(li_index,5,ls_str); lv_data = recodData->GetCollect("TJTP");
ls_str = vartostr(&lv_data);
m_list.SetItemText(li_index,6,ls_str); li_index++;
recodData->MoveNext();
}
recodData.Release();
}
m_AddFlag = TRUE;
}
//关闭功能
void CVehQueryDlg::OnButton5() 
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
}void CVehQueryDlg::OnItemchangedList3(NMHDR* pNMHDR, LRESULT* pResult) 
{
// TODO: Add your control notification handler code here
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;

if (m_AddFlag)
{
//取图片显示
for (int i=0;i<m_list.GetItemCount();i++)
{
if (m_list.GetItemState(i,LVIS_SELECTED)==LVIS_SELECTED)
{
CString ls_fileName;
ls_fileName = m_list.GetItemText(i,6);
LoadImgFileShow(ls_fileName);
break;
}
}
}

*pResult = 0;
}
]