You would have thunk .NET would do well with database classes as db objects work well in COM. Seems I'm not the only one frustrated, but this WB code cannot even open a connection. I have attached the zipped access db used in the script.
;Winbatch 2013 - CLR - OLEDB {baby steps}
;
;
;Stan Littlefield July 7, 2013
;////////////////////////////////////////////////////////////////////////////////////////////////////////
cACCDB = Dirscript():"test.accdb"
If ! FileExist(cACCDB) Then Terminate(@TRUE,"Cannot Continue","Missing Database File: ":cACCDB)
cConn = 'Provider=Microsoft.ACE.OLEDB.12.0;data source=':cACCDB:';Connect Timeout=30' ;oProvider.ConnectionTimeout = 30 not needed
ObjectClrOption("use","System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
;got errors trying to set oProvider.ConnectionString so used this class
oBuilder = ObjectClrNew("System.Data.OleDb.OleDbConnectionStringBuilder")
oBuilder.ConnectionString = cConn
oConn = oBuilder.ConnectionString
message("debug",oConn)
;do far so good, but cannot open connection
;used either
oProvider = ObjectClrNew("System.Data.OleDb.OleDbConnection",oConn)
;or
;oProvider = ObjectClrNew("System.Data.OleDb.OleDbConnection")
;oProvider.ConnectionString = oConn
message("debug",oProvider.ConnectionString)
;invocation error here
oProvider.Open()
oTables = oProvider.GetSchema("Tables")
oTables = 0
oProvider.Dispose()
oProvider=0
Exit