Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any chance to implement ADODB #185

Open
efreibe opened this issue Mar 23, 2021 · 7 comments
Open

Any chance to implement ADODB #185

efreibe opened this issue Mar 23, 2021 · 7 comments
Labels
enhancement New feature or request help wanted Good candidate for others to work on

Comments

@efreibe
Copy link

efreibe commented Mar 23, 2021

I'm wondering if it's too hard to implement ADODB (Connection, Command and Recordset at least),
I've tried, but I can't figure out how to implement those interfaces completely.

I have some questions, for example, the typelib has definitions like object, that I do
not how to convert to dart (I found over there that should be a Long value?).
And I've not found how to implement enum types.

Moreover I do not know how to calculate the vtable indexes of methods and properties.

Here is an example of _Connection Interface that I've tried to implement, I do not know if the tool I've used reorders methods and properties, this makes more confusing to calculate vtable indexes.

There is another way to tackle this? For example, using IDispatch/Invoke like old Visual Basic does?

Any help would be appreciated. Thank you.

[Guid("00000550-0000-0010-8000-00aa006d2ea4")]
interface _Connection
{
   /* Methods */
   void Close();
   Recordset Execute(string CommandText, [Out,Optional] Object& RecordsAffected, [Optional] int Options);
   int BeginTrans();
   void CommitTrans();
   void RollbackTrans();
   void Open([Optional] string ConnectionString, [Optional] string UserID, [Optional] string Password, [Optional] int Options);
   Recordset OpenSchema(SchemaEnum Schema, [Optional] object Restrictions, [Optional] object SchemaID);
   void Cancel();
   /* Properties */
   Properties Properties { get; }
   string ConnectionString { get; set; }
   int CommandTimeout { get; set; }
   int ConnectionTimeout { get; set; }
   string Version { get; }
   Errors Errors { get; }
   string DefaultDatabase { get; set; }
   IsolationLevelEnum IsolationLevel { get; set; }
   int Attributes { get; set; }
   CursorLocationEnum CursorLocation { get; set; }
   ConnectModeEnum Mode { get; set; }
   string Provider { get; set; }
   int State { get; }
}
@timsneath
Copy link
Contributor

I'd love to understand the scenario better -- what are you building where ADO on the client is the right choice?

While it's theoretically possible, I think you might be better off with something like this: https://pub.dev/packages/dart_mssql

@efreibe
Copy link
Author

efreibe commented Mar 23, 2021

I need to support another server than mssql.
Here is the link:

http://devzone.advantagedatabase.com/dz/content.aspx?key=20&Release=19

I'm thinking that adodb is the best option I have in this situation. Besides adodb can handle a variety of additional data stores like excel.

Do you see a better option here? There are other libraries in that page, I think that addressing the native library would be a mess.

@timsneath
Copy link
Contributor

Oh my! Yeah, that's quite a challenge. If I were building this today, I would probably create a native component in a more COM-friendly that does the heavy lifting work of getting data out of ADODB, and then expose that to Dart through a simpler interface.

What you're describing is theoretically possible with Dart, but you're pioneering into new territory. While I have IDispatch wired up, I've not been able to successfully invoke a method using it. Unclear yet whether it's bad pointer management on my side or whether there's something more fundamentally broken.

If you're comfortable to be a pioneer, you can check the experimentation I've done so far here: https://github.com/timsneath/win32/blob/dotnet/example/dotnet/invoke.dart

@timsneath timsneath added help wanted Good candidate for others to work on enhancement New feature or request labels Mar 29, 2021
@efreibe
Copy link
Author

efreibe commented Apr 3, 2021

I will take a look and see what can I do... thank you

@efreibe
Copy link
Author

efreibe commented Apr 5, 2021

@timsneath I've taken a look to the code you left in the past comment, I've made some arrangements and came up with the code below. Hope helps to complete the invoke example:

testinvoke.zip

I've added some free functions to avoid leaks, but being a short example maybe could be better to remove them.

I will continue investigating how to port ADODB. Thank you.

@timsneath
Copy link
Contributor

This is fantastic! Thank you. You've fixed my pointer bug and this works nicely now.

I'll tidy up the sample and try and use it to do something slightly more sophisticated, but this gets us a big step closer to something like ADODB. Thank you.

@timsneath timsneath linked a pull request Apr 6, 2021 that will close this issue
@timsneath timsneath removed a link to a pull request Apr 6, 2021
@efreibe
Copy link
Author

efreibe commented Apr 6, 2021

You're welcome, let me know if you need any further help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Good candidate for others to work on
Projects
None yet
Development

No branches or pull requests

2 participants