void CbltlDlg::OnButton4()
{
UpdateData(true);
CString strDBConnection;
CString strSql;
strDBConnection = "Provider=OraOLEDB.Oracle; Data Source=CTM_192.168.3.5; User Id=system; Password=manager";
CAdoConnection adoConnection;
CString str1,str2,str,str10;
CString st3,st4,st5,st6,st7,str17,str26;
str1.Format(_T("%d"),m_1_1);
str2.Format(_T("%d"),m_1_2);
str=str1+str2;
st3.Format(_T("%d"),m_2_1);
st4.Format(_T("%d"),m_2_2);
st5.Format(_T("%d"),m_2_3);
st7.Format(_T("%d"),m_2_4);
st6=st3+st4+st5+st7;
str10=m_3_1+m_3_2+m_3_3+m_3_4;
adoConnection.Open(strDBConnection);
CAdoRecordSet rs(&adoConnection);
strSql.Format("select * from ZHONGYI.T10 where B1='%s' and B2='%s' and B3='%s'",str,st6,str10);
if(rs.Open(strSql))
AfxMessageBox("select successful");
else {
AfxMessageBox("select failure");
}
if ((!rs.IsEOF())&(!rs.IsBOF()))
{
rs.GetCollect(_T("B4"), str17);
m_4_1=_ttoi(str17.Left(1));
m_4_2=_ttoi(str17.Mid(1,1));
m_4_3=_ttoi(str17.Mid(2,1));
m_4_4=_ttoi(str17.Mid(3,1));
m_4_5=_ttoi(str17.Mid(5,1));
m_4_6=_ttoi(str17.Mid(6,1));
m_4_7=_ttoi(str17.Mid(8,1));
m_4_8=_ttoi(str17.Mid(9,1));
rs.GetCollect(_T("B5"), m_5);
rs.GetCollect(_T("B6"), str26);
m_6_1=_ttoi(str26.Left(1));
m_6_2=_ttoi(str26.Mid(1,1));
m_6_3=_ttoi(str26.Mid(2,1));
m_6_4=_ttoi(str26.Mid(3,1));
m_6_5=_ttoi(str26.Mid(5,1));
m_6_6=_ttoi(str26.Mid(6,1));
m_6_7=_ttoi(str26.Mid(8,1));
m_6_8=_ttoi(str26.Mid(9,1));
rs.GetCollect(_T("B7"), m_7);
rs.GetCollect(_T("B8"), m_8);
rs.GetCollect(_T("B9"), m_9);
rs.GetCollect(_T("B10"), m_10);
rs.GetCollect(_T("B11"), m_11);
rs.GetCollect(_T("B12"), m_12);
rs.GetCollect(_T("B13"), m_13);
rs.GetCollect(_T("B14"), m_14);
rs.GetCollect(_T("B16"), m_16);
rs.GetCollect(_T("B17"), m_17);
rs.GetCollect(_T("B18"), m_18);
}
else
{
AfxMessageBox("没有记录!");
return;
}
UpdateData(false);
adoConnection.Close();
rs.Close();
均报错,“没有记录”,而数据库里明明存在着记录。
{
UpdateData(true);
CString strDBConnection;
CString strSql;
strDBConnection = "Provider=OraOLEDB.Oracle; Data Source=CTM_192.168.3.5; User Id=system; Password=manager";
CAdoConnection adoConnection;
CString str1,str2,str,str10;
CString st3,st4,st5,st6,st7,str17,str26;
str1.Format(_T("%d"),m_1_1);
str2.Format(_T("%d"),m_1_2);
str=str1+str2;
st3.Format(_T("%d"),m_2_1);
st4.Format(_T("%d"),m_2_2);
st5.Format(_T("%d"),m_2_3);
st7.Format(_T("%d"),m_2_4);
st6=st3+st4+st5+st7;
str10=m_3_1+m_3_2+m_3_3+m_3_4;
adoConnection.Open(strDBConnection);
CAdoRecordSet rs(&adoConnection);
strSql.Format("select * from ZHONGYI.T10 where B1='%s' and B2='%s' and B3='%s'",str,st6,str10);
if(rs.Open(strSql))
AfxMessageBox("select successful");
else {
AfxMessageBox("select failure");
}
if ((!rs.IsEOF())&(!rs.IsBOF()))
{
rs.GetCollect(_T("B4"), str17);
m_4_1=_ttoi(str17.Left(1));
m_4_2=_ttoi(str17.Mid(1,1));
m_4_3=_ttoi(str17.Mid(2,1));
m_4_4=_ttoi(str17.Mid(3,1));
m_4_5=_ttoi(str17.Mid(5,1));
m_4_6=_ttoi(str17.Mid(6,1));
m_4_7=_ttoi(str17.Mid(8,1));
m_4_8=_ttoi(str17.Mid(9,1));
rs.GetCollect(_T("B5"), m_5);
rs.GetCollect(_T("B6"), str26);
m_6_1=_ttoi(str26.Left(1));
m_6_2=_ttoi(str26.Mid(1,1));
m_6_3=_ttoi(str26.Mid(2,1));
m_6_4=_ttoi(str26.Mid(3,1));
m_6_5=_ttoi(str26.Mid(5,1));
m_6_6=_ttoi(str26.Mid(6,1));
m_6_7=_ttoi(str26.Mid(8,1));
m_6_8=_ttoi(str26.Mid(9,1));
rs.GetCollect(_T("B7"), m_7);
rs.GetCollect(_T("B8"), m_8);
rs.GetCollect(_T("B9"), m_9);
rs.GetCollect(_T("B10"), m_10);
rs.GetCollect(_T("B11"), m_11);
rs.GetCollect(_T("B12"), m_12);
rs.GetCollect(_T("B13"), m_13);
rs.GetCollect(_T("B14"), m_14);
rs.GetCollect(_T("B16"), m_16);
rs.GetCollect(_T("B17"), m_17);
rs.GetCollect(_T("B18"), m_18);
}
else
{
AfxMessageBox("没有记录!");
return;
}
UpdateData(false);
adoConnection.Close();
rs.Close();
均报错,“没有记录”,而数据库里明明存在着记录。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货