Importing from a Database DatabaseOrigin C includes the ability to import data from a databaseSQL into a worksheet. The following example shows how to do this by importing an Access database file, included in the Origin Samples folder. An ADODB.Reocrdset object can refer to MSDN. To find out how to construct your connection string, refer to DbEdit X-Function
Object ocora; try { ocora = CreateObject("ADODB.Recordset"); } catch(int nError) { out_str("Failed to create ADODB.Recordset"); return FALSE; } // Import stars.mdb from the Origin Samples folder string strDatabaseFile = GetAppPath(1) + "Samples\\Import and Export\\stars.mdb"; // Prepare the database connection string string strConn; strConn.Format("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=%s; User ID=admin; Password=;", strDatabaseFile); // Prepare the SQL string string strQuery = "Select Stars.Index, Stars.Name, Stars.LightYears, Stars.Magnitude From Stars"; ocora.CursorLocation = adUseClient; try { ocora.open(strQuery, strConn, 1, 3); } catch(int nError) { out_str("Failed to open Oracle database"); return FALSE; } Worksheet wks; wks.Create(); //put data into the worksheet. BOOL bRet = wks.PutRecordset(ocora); out_int("bRet = ", bRet); return bRet;