Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Programming (http://www.go4expert.com/forums/programming-forum/)
-   -   DAO to ADO (http://www.go4expert.com/forums/dao-to-ado-t22849/)

leaderaa 28Jul2010 19:50

DAO to ADO
 
Hi all,

i have a code in which the data is being inserted in MS Access using DAO in VC++. but now since the usage has increased i want to change it and insert the data in SQL Server 08. Can any one help me out on this please, on how to get the data saved in SQL by using either ADO or ODBC from VC++.

Thanks in advance....

i am also pasting the current code i have which insert the data in MDB.

Here is my code:::

Code:

daoDB.Open(filename);
        daoTD.Open("Position");
        daoRecSet.Open(&daoTD);
        if (daoRecSet.CanAppend())
        {
                daoRecSet.AddNew();
                daoRecSet.SetFieldValue("UnitID",(LPCTSTR) TransString(UnitID));
                daoRecSet.SetFieldValue("GPSDateTime",(LPCTSTR) GPSDateTime);
                daoRecSet.SetFieldValue("RTCDateTime",(LPCTSTR) RTCDateTime);
                daoRecSet.SetFieldValue("SendDateTime",(LPCTSTR) SendDateTime);
                daoRecSet.SetFieldValue("Longitude",(LPCTSTR) TransString(PosData.Longitude));
                daoRecSet.SetFieldValue("Latitude",(LPCTSTR) TransString(PosData.Latitude));
                daoRecSet.SetFieldValue("Heading",(LPCTSTR) TransString(PosData.Heading));
                daoRecSet.SetFieldValue("ReportID",(LPCTSTR) TransString(PosData.ReportID));
                daoRecSet.SetFieldValue("Odometer",(LPCTSTR) TransString(PosData.Odometer));
                daoRecSet.SetFieldValue("GPSHDOP",(LPCTSTR) TransString(PosData.GPSHDOP));
                daoRecSet.SetFieldValue("InputsStatus",(LPCTSTR) TransString(PosData.AllInput));
                daoRecSet.SetFieldValue("VSSSpeed",(LPCTSTR) TransString(PosData.VSSSpeed));
                daoRecSet.SetFieldValue("OutputsStatus",(LPCTSTR) TransString(PosData.AllOutput));
                daoRecSet.SetFieldValue("AnalogInput#01",(LPCTSTR) TransString(PosData.AnalogInput[0]));
                if( strlen((char*)PosData.DriverID) != 0)
                        daoRecSet.SetFieldValue("DriverID",(LPCTSTR) PosData.DriverID);
                daoRecSet.SetFieldValue("TPSensor#01",(LPCTSTR) TransString(PosData.Temperature[0]));
                daoRecSet.SetFieldValue("TPSensor#02",(LPCTSTR) TransString(PosData.Temperature[1]));
                if( strlen((char*)PosData.TextMessage) != 0)
                        daoRecSet.SetFieldValue("TextMessage",(LPCTSTR) PosData.TextMessage);

                daoRecSet.Update();
        }

}



All times are GMT +5.5. The time now is 01:59.