odbcconnection-stringadodbdexteritydynamics-gp

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified [Dynamics GP]


I'm trying to create a form upload transaction from excel to table via dexterity tools then copy some code from samples scripts. The steps i got from references similarly on these scripts:

conn.ConnectionString = 
   "Driver={Microsoft Excel Driver (*.xls)};" + 
   "Driverid=790;" + 
   "Dbq=C:\MyPath\SpreadSheet.xls;" + 
   "DefaultDir=C:\MyPath;"; 
conn.Open();

another sample from my superior which script looks like these:

sheetbuf = itemname('(L) Sheet' of window PMS_Upload_Budget, '(L) Sheet' of window PMS_Upload_Budget);
buf1 = sheetbuf;
sheetbuf = "[" + sheetbuf +"$]";
recordset = COM_CreateObject("ADODB.Recordset");

sDriverExcel="{Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)}";
sConString="DRIVER="+sDriverExcel+";DriverId=790;DBQ="+'(L) Native Path'+";DefaultDir=";

recordset.Open("SELECT COUNT(*) as RowCount FROM " + sheetbuf, sConString);
row = recordset.Fields.Item[0].Value;

recordset.Close();
recordset.Open("SELECT * FROM " + sheetbuf, sConString);
col = recordset.Fields.Count[];

When i tried to sample both of those scripts, gain error like these warning

Then, i ask for another assistance from my other superior. He give me these script: sample2

So, i tried to follow his assistance by installing AccessDatabaseEngine_X64.exe and changing the connection string with these script:

sConString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" 
+ '(L) FullPath' + ";Extended Properties=""Excel 12.0 Xml; HDR=YES;IMEX=1"";";

Then again, got these error: Provider cannot be found

Recently, i look the connection string on excel power query and tried to transfer data inside a table to other workbook. Then, this window comes up to ask my credentials. So, i assume ODBC without DSN from my first references not working properly. Then, i tried to add these script to power query:

conn.ConnectionString = 
          "Dsn=DsnName;" + 
          "Uid=UserName;" + 
          "Pwd=Secret;"; 

But, the window shows a warning says "The Connection property 'uid' can only be provided using credentials. So, i stuck finding alternative way to input pwd parameter into power query nor dexterity script.

Latest thing i ever tried is looking at OLE/COM object viewer(hundreds objects) and process monitor(millions event). Any tips regarding similar issues could be useful here, thanks.


Solution

  • i fix my previous script into this from my friend references

    sheetbuf = itemname('(L) ExcelRow' of window Integrate_Transaction, '(L) ExcelRow' of window Integrate_Transaction);
    buf1 = sheetbuf;
    sheetbuf = "[" + sheetbuf +"$]";
    connection = COM_CreateObject("ADODB.Connection");
    recordset = COM_CreateObject("ADODB.Recordset");
    
    conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + '(L) FullPath' + ";Extended Properties=Excel 8.0;";
    connection.Open(conString);
    recordset.Open("SELECT COUNT(*) as RowCount FROM " + sheetbuf , connection, ADODB.adOpenDynamic, ADODB.adLockOptimistic);
    row = recordset.Fields.Item[0].Value;
    
    recordset.Close();
    

    So, i suspected the dexterity library should install something else for those two other constring. Thanks for trying to answer my confusion tho, i'd appreciate more answers for those two constring ^^