OLE DB (C++) y SQL
Hola. Espero que puedes ayudarme. Tengo un problema con OLE DB y un servidor SQL.
Aprendo c++ y intento aprender las maneras variopintas de acceso de datos en C++. He empezado con OLE DB pero lo estoy encontrando difícil.
Tengo un servidor SQL y he usado el asistente de MFC (en Visual Studio .Net) para creer un proyecto que accede al servidor. Intento añadir un registro y he leído la ayuda.
He puesto un button que prepara un CRecordset y llama a CRecordset. Insert(). La programa me dice que el Insert() funcionó pero después el registro no se encuentre en el base de datos.
¿Puedes ayudarme?
Gracias,
Matt
--------
El código del button es:
void CTestSQL4View::OnBnClickedButtonUpdate()
{
USES_CONVERSION;
m_pSet->m_ShipperID = 4;
_tcscpy(m_pSet->m_CompanyName, "Matt's Shipping");
_tcscpy(m_pSet->m_Phone, "(503) 555-9931");
m_ShipperIDCtrl.SetWindowText("4");
m_CompanyNameCtrl.SetWindowText("Matt's Shipping");
m_PhoneCtrl.SetWindowText("(503) 555-9931");
m_pSet->m_dwShipperIDStatus = DBSTATUS_S_OK;
m_pSet->m_dwCompanyNameStatus = DBSTATUS_S_OK;
m_pSet->m_dwPhoneStatus = DBSTATUS_S_OK;
m_pSet->m_dwShipperIDLength = m_ShipperIDCtrl.GetWindowTextLength();
m_pSet->m_dwCompanyNameLength = m_CompanyNameCtrl.GetWindowTextLength();
m_pSet->m_dwPhoneLength = m_PhoneCtrl.GetWindowTextLength();
if (m_pSet->Insert(5)) {
::AfxMessageBox("Insert successful", 0, 1);
} else {
::AfxMessageBox("Insert unsuccessful", 0, 1);
}
m_pSet->UpdateAll();
m_state_AddRecord = false;
CButton* m_tempButton = (CButton*) GetDlgItem(IDC_BUTTON_UPDATE);
m_tempButton->EnableWindow(false);
m_tempButton = (CButton*) GetDlgItem(IDC_BUTTON_CANCEL);
m_tempButton->EnableWindow(false);
}
Aprendo c++ y intento aprender las maneras variopintas de acceso de datos en C++. He empezado con OLE DB pero lo estoy encontrando difícil.
Tengo un servidor SQL y he usado el asistente de MFC (en Visual Studio .Net) para creer un proyecto que accede al servidor. Intento añadir un registro y he leído la ayuda.
He puesto un button que prepara un CRecordset y llama a CRecordset. Insert(). La programa me dice que el Insert() funcionó pero después el registro no se encuentre en el base de datos.
¿Puedes ayudarme?
Gracias,
Matt
--------
El código del button es:
void CTestSQL4View::OnBnClickedButtonUpdate()
{
USES_CONVERSION;
m_pSet->m_ShipperID = 4;
_tcscpy(m_pSet->m_CompanyName, "Matt's Shipping");
_tcscpy(m_pSet->m_Phone, "(503) 555-9931");
m_ShipperIDCtrl.SetWindowText("4");
m_CompanyNameCtrl.SetWindowText("Matt's Shipping");
m_PhoneCtrl.SetWindowText("(503) 555-9931");
m_pSet->m_dwShipperIDStatus = DBSTATUS_S_OK;
m_pSet->m_dwCompanyNameStatus = DBSTATUS_S_OK;
m_pSet->m_dwPhoneStatus = DBSTATUS_S_OK;
m_pSet->m_dwShipperIDLength = m_ShipperIDCtrl.GetWindowTextLength();
m_pSet->m_dwCompanyNameLength = m_CompanyNameCtrl.GetWindowTextLength();
m_pSet->m_dwPhoneLength = m_PhoneCtrl.GetWindowTextLength();
if (m_pSet->Insert(5)) {
::AfxMessageBox("Insert successful", 0, 1);
} else {
::AfxMessageBox("Insert unsuccessful", 0, 1);
}
m_pSet->UpdateAll();
m_state_AddRecord = false;
CButton* m_tempButton = (CButton*) GetDlgItem(IDC_BUTTON_UPDATE);
m_tempButton->EnableWindow(false);
m_tempButton = (CButton*) GetDlgItem(IDC_BUTTON_CANCEL);
m_tempButton->EnableWindow(false);
}
1 Respuesta
Respuesta
1