Jump to page: 1 2 3
Thread overview
D / GtkD for SQL Server
Oct 20, 2013
John Joyus
Oct 20, 2013
Jacob Carlborg
Oct 20, 2013
Jacob Carlborg
Oct 20, 2013
Mike Wey
Oct 20, 2013
John Joyus
Oct 20, 2013
Jacob Carlborg
Oct 21, 2013
John Joyus
Oct 21, 2013
Jacob Carlborg
Oct 20, 2013
Adam D. Ruppe
Oct 21, 2013
John Joyus
Oct 21, 2013
Adam D. Ruppe
Oct 21, 2013
John Joyus
Oct 21, 2013
Adam D. Ruppe
Oct 21, 2013
John Joyus
Oct 21, 2013
Adam D. Ruppe
Oct 22, 2013
John Joyus
Oct 25, 2013
Adam D. Ruppe
Oct 25, 2013
John Joyus
Oct 20, 2013
ilya-stromberg
Oct 25, 2013
Gary Willoughby
Oct 27, 2013
John Joyus
Oct 27, 2013
Gary Willoughby
Oct 31, 2013
ilya-stromberg
Oct 31, 2013
Jacob Carlborg
Nov 06, 2013
John J
Nov 06, 2013
Jacob Carlborg
Nov 06, 2013
John J
Nov 07, 2013
Jacob Carlborg
October 20, 2013
I am learning D and itching to create some small tools (basically Windows executables) for our internal use, but any tool I think of creating also needs some support for SQL Server! So my question is:

1). Does D has any support for MSSQL?

I need the ability to connect to a SQL Server and run a SQL script (the script I construct based on user inputs) and capture its return value, just a number. (No need to insert or update any records).

Oh, btw, another question, unrelated to the above:

2). If I build with GtkD, it generates about 3.5 MB executable. Does this contain everything or do I still have to distribute anything with it to make it work on new Windows machines?

Thanks in advance.
October 20, 2013
On 2013-10-20 10:13, John Joyus wrote:
> I am learning D and itching to create some small tools (basically
> Windows executables) for our internal use, but any tool I think of
> creating also needs some support for SQL Server! So my question is:
>
> 1). Does D has any support for MSSQL?
>
> I need the ability to connect to a SQL Server and run a SQL script (the
> script I construct based on user inputs) and capture its return value,
> just a number. (No need to insert or update any records).

I would say your best bet is to create bindings to FreeTDS. It's an open source library that can connect to SQL Server.

I actually tried to do that once, but I never managed to connect to the server/database, for some reason. I C version worked fine but not when I ported it do D.

This is the D version:

http://pastebin.com/7tGyytDh

This is the tds file:

http://pastebin.com/JCA8XQH0

This is the C version:

http://pastebin.com/FWJM4B6X

You just need to fill in the constants at the top. Please let me know if you get the D version working.

-- 
/Jacob Carlborg
October 20, 2013
On 2013-10-20 11:37, Jacob Carlborg wrote:

> You just need to fill in the constants at the top. Please let me know if
> you get the D version working.

You need to change the actual SQL select statement as well.

-- 
/Jacob Carlborg
October 20, 2013
On 10/20/2013 10:13 AM, John Joyus wrote:
> 2). If I build with GtkD, it generates about 3.5 MB executable. Does
> this contain everything or do I still have to distribute anything with
> it to make it work on new Windows machines?
>
> Thanks in advance.

You'll need to have the Gtk+ runtime installed on the machine.

-- 
Mike Wey
October 20, 2013
On Sunday, 20 October 2013 at 08:13:35 UTC, John Joyus wrote:
> I am learning D and itching to create some small tools (basically Windows executables) for our internal use, but any tool I think of creating also needs some support for SQL Server! So my question is:
>
> 1). Does D has any support for MSSQL?

Look at the OpenDBX bindings:
https://github.com/rikkimax/Derelict3-Extras/tree/master/import/derelict/opendbx

It supports a lot of databases, including SQL Server.

Disclaimer: I didn't use it.
October 20, 2013
On 10/20/2013 09:39 AM, Mike Wey wrote:
> On 10/20/2013 10:13 AM, John Joyus wrote:
>> 2). If I build with GtkD, it generates about 3.5 MB executable. Does
>> this contain everything or do I still have to distribute anything with
>> it to make it work on new Windows machines?
>>
>> Thanks in advance.
>
> You'll need to have the Gtk+ runtime installed on the machine.
>

Thank you all for the responses.

Regarding the GUI part, all I really need is a form and a bunch of buttons. Can I do that through pure Windows API in D to create a small stand-alone executable that does everything by itself?

If that is possible, any links to an example D code?

Thanks.




October 20, 2013
On 2013-10-20 19:24, John Joyus wrote:

> Thank you all for the responses.
>
> Regarding the GUI part, all I really need is a form and a bunch of
> buttons. Can I do that through pure Windows API in D to create a small
> stand-alone executable that does everything by itself?
>
> If that is possible, any links to an example D code?

You can use DWT:

https://github.com/d-widget-toolkit/dwt

For examples, just search for SWT.

-- 
/Jacob Carlborg
October 20, 2013
On Sunday, 20 October 2013 at 17:24:30 UTC, John Joyus wrote:
> Regarding the GUI part, all I really need is a form and a bunch of buttons. Can I do that through pure Windows API in D to create a small stand-alone executable that does everything by itself?

yup. I started a thing to do it, but haven't finished it yet

https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff

Grab the files simpledisplay.d, color,d and minigui.d. Lots of stuff doesn't work, and the stuff that does work is still subject to change... but if all ou need are the basics, it might be good enough as it is.

Then compile:

dmd yourapp.d simpledisplay.d color.d minigui.d

and it should just work. If you avoid phobos throughout your code, you can get stand-alone executables about 230 KB in size. With phobos, you'll probably add 200-700 KB, depending on how much you use.

Add " -L/SUBSYSTEM:WINDOWS:5.0" (no quotes) to the command line if you don't want a console window to pop up. If you use a resource and xml manifest, this supports visual theme styles on XP+ too. (search MSDN if you want to learn more)

(btw there's also database.d and mssql.d in there that might interest you. mssql.d uses ODBC, but the truth is I've never actually tested it, so I don't know if it even compiles.)




minigui.d uses native Windows functions for the most part, if you look at the source, you can see where there's HWNDs and so on (and simpledisplay.d creates the windows and manages the event loop, you can find a WndProc in there), but does its own layout based on min/max size, stretchiness, and a handful of other virtual functions. This is kinda a pain to customize at this point, but it works pretty ok if the default is good for you (fill all available space vertically).

The event model is based on javascript, you use widget.addEventListener(type, handler).


Here's an example program:

import arsd.minigui;

void main() {
	auto window = new MainWindow();

        // the constructor often takes a label and a parent
	auto checkbox = new Checkbox("Useful?", window);

        // use HorizontalLayouts to put things side-by-side
	auto field = new HorizontalLayout(window);
	auto lbl = new TextLabel("Name:", field);
	auto edit = new LineEdit(field);

	auto buttonSet = new HorizontalLayout(window);
	auto cancelButton = new Button("Cancel", buttonSet);
	auto okButton = new Button("OK", buttonSet);

        // the triggered event is like click, but also works with keyboard activation
        // other possible events are click, mouseover, mouseenter, and a few others from javascript, search the minigui.d source for EventType for a list so far
	cancelButton.addEventListener(EventType.triggered, {
		window.close();
	});

	okButton.addEventListener(EventType.triggered, {
               // checking the checkbox state...
		if(checkbox.isChecked)
                       // message boxes are done right now with custom windows and are modeless. you actually prolly shouldn't use them, perhaps use the raw Windows function instead
			auto mb = new MessageBox("You said your name is : " ~ edit.content); // the box's content property gets its text. only ASCII right now, i gotta fix this to use GetWindowTextW instead of A...
		else
			auto mb = new MessageBox("You said this is useless, " ~ edit.content);
		window.close();
	});

        // run the event loop. it terminates when the last window is closed by your program or by the user.
	window.loop();
}




If it works for you, cool, let me know if there's anything I can do to make it better for you and I'll try to make it happen.


There's also DWT you might want to look at, like Jacob said. It is a pretty complete port of the Java SWT toolkit so will probably offer more functionality than my incomplete, minimal file here.
October 21, 2013
On 10/20/2013 01:56 PM, Jacob Carlborg wrote:

> You can use DWT:
>
> https://github.com/d-widget-toolkit/dwt
>
> For examples, just search for SWT.
>

Thanks. Does it need Java runtime on end user's machine?


October 21, 2013
On 10/20/2013 02:15 PM, Adam D. Ruppe wrote:
> On Sunday, 20 October 2013 at 17:24:30 UTC, John Joyus wrote:
>> Regarding the GUI part, all I really need is a form and a bunch of
>> buttons. Can I do that through pure Windows API in D to create a small
>> stand-alone executable that does everything by itself?
>
> yup. I started a thing to do it, but haven't finished it yet
>
> https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff
>
>
> Grab the files simpledisplay.d, color,d and minigui.d. Lots of stuff
> doesn't work, and the stuff that does work is still subject to change...
> but if all ou need are the basics, it might be good enough as it is.
>
> Then compile:
>
> dmd yourapp.d simpledisplay.d color.d minigui.d
>
> and it should just work. If you avoid phobos throughout your code, you
> can get stand-alone executables about 230 KB in size. With phobos,
> you'll probably add 200-700 KB, depending on how much you use.
>
> Add " -L/SUBSYSTEM:WINDOWS:5.0" (no quotes) to the command line if you
> don't want a console window to pop up. If you use a resource and xml
> manifest, this supports visual theme styles on XP+ too. (search MSDN if
> you want to learn more)
>
> (btw there's also database.d and mssql.d in there that might interest
> you. mssql.d uses ODBC, but the truth is I've never actually tested it,
> so I don't know if it even compiles.)
>
>

This is cool! I am able to compile your example. It creates a small 225 KB executable!

Btw, I had to comment out the lines that contain TextLabel and the .content in the example code as it fails to compile with following errors:
- undefiend identifier TextLabel
- no property 'content' for type 'arsd.minigui.LineEdit'

I have not tried the database.d and mssql.d files yet.

Thanks.


« First   ‹ Prev
1 2 3