1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

DAO to ADO

Discussion in 'Programming' started by leaderaa, Jul 28, 2010.

  1. leaderaa

    leaderaa New Member

    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();
    	}
    
    }
    
     

Share This Page