Sign in to follow this  
Followers 0
Raestlin

Script for all database connections...

20 posts in this topic

#1 ·  Posted (edited)

I have created an entirely new database code that does not require ODBC connections.

I have re-worked the code since this original post, so see my last post for the updates

{new code in my last post}

Here's what you need to change:

1) Use ONE of the two "Dim $query" commands (depending on whether you are using a text file or not).

2) Change the "Dim $query" command to equal whatever query statement you need.

3) Use ONE of the five "Dim $DSN" command (depending on what database type you are connecting to).

Modifications I made:

1) I removed the need for ODBC connections.

2) I removed the prompt for the query command, since you will hard code this anyways in most cases.

3) I removed the popup telling you how many records were retrieved. Instead, the window title shows you.

4) I commented the code to make it easy to understand.

5) I completely re-wrote the code to be more dynamic and to be used as a UDF now.

Edited by Raestlin

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Thats great..

Any plans create a function so you can write to those databases?

Edited by blitzkrg

Share this post


Link to post
Share on other sites

Thats great..

Any plans create a function so you can write to those databases?

If others are interested, I will create a full-fledged code with add/update/modify, delete, etc.

It may take me a couple days, but the connector is the hardest part.

Once the connector is in place, the other code is the same for everything.

I'll look into it and create a GUI for it as well.

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

for me i'm mostly interested in a read/write UDF

i would like to be able to read and write to specific rows also

some of the other UDF's could own write to the last row

Share this post


Link to post
Share on other sites

for me i'm mostly interested in a read/write UDF

i would like to be able to read and write to specific rows also

some of the other UDF's could own write to the last row

OK, I'm currently in the process of completely re-writing the code.

I'm extremely anal about my coding and I saw way too much wrong with the

previous person's code that I initially started with. It was good, but not good enough

for me. You'll understand when you see my new code how anal I am.

I like things to be more dynamic.

I'm creating it to be more of an "include.au3" code (I'm guessing that's what you all consider a UDF?).

I am also creating a GUI wrapper around the code for example purposes.

It's going to take me longer than the initial few days I mentioned since I'm completely

re-writing everything. I will post it once I have a working beta and then I can add

modifications once it's in beta.

First round, I will include display, write, and delete of records.

Share this post


Link to post
Share on other sites

First round, I will include display, write, and delete of records.

OK, I wanted to get my base code up to all you guys since I done

with a new UDF version of the database code. It currently only displays

records, but what do you expect after only one day of a complete re-write?? :-) LOL

I cleaned up a lot of the code, but there's not any error checking just yet.

That is still to come as well as writing and deleting records.

I'm attaching a zip file with the UDF and example code.

Database.zip

The "Database.au3" is the UDF that needs to go in your AutoIt include folder.

The "ADODB_Gui2.au3" is the sample GUI wrapper.

The "test.mdb" is the sample database that has bogus data in it.

Make sure that the access .mdb file is in the same folder as the GUI wrapper before it will run.

Share this post


Link to post
Share on other sites

@Raestlin

Your script was very useful. It saved me a lot of time figuring out the database connections.

Thanks for the working example.

Share this post


Link to post
Share on other sites

nice :)

i needed something like this ...

Thanks. :-)

Check back later and I will have more added to the UDF that will include

writing and deleting records.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

3) Use ONE of the five "Dim $DSN" command (depending on what database type you are connecting to).

Fantastic Post Raestlin.

I've been struggling with trying to connect to an AS400 database without resorting to ODBC for a long time now, and had no success. How did you determine what the DSN connect strings should be, and maybe I can add another one?

Thanks

Walkabout

Edited by Walkabout

Share this post


Link to post
Share on other sites

OK, been a while.

Not allowed to script at work any more.

Been learning VB at work and can only script at home now.

Here's my latest addition to the UDF.

You can now delete records.

I've attached my sample GUI as well that I've been working on.

Future changes:

* Function to update records

* Function (wizard) to help you build query string

* Function (wizard) to help you build connection string

Database UDF and Sample GUI: {zip file}

database.zip

Share this post


Link to post
Share on other sites

hi Raestlin,

nice au3.function, it works fine for me!!!

Do you update the UDF with a function for adding/updating of records ?

mfg, Laetterman

Share this post


Link to post
Share on other sites

Nice Raestlin.

Gets me going again, I had hit a snag with .mdb files. This got me going again.

Would love to see functions for sorting, adding and modifying records.

Thanks.

Share this post


Link to post
Share on other sites

If my query is not found. I get this error

Line 70 (File "C:\Program Files\AutoIt3\beta\Include\Database.au3"):graphic 722 $aRsData = .GetRows(-1)

$aRsData = .GetRows(-1)^ ERROR

Error: Error in expression.

Can anyone tell me how can I solve it?

Thank you

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

Hi Raestlin

These functions are awesome. I was in a mess trying to create my useless scripts (latest project is a UK-style secondary school register system that mimics SIMS Lesson Monitor, but also has a Staff Chat option for requesting support, photocopies, etc.), but I could not get my head round my 250+ INI files to register Pupils, Classes, Teachers, Lessons, Timetables, Etc. - My INIRead functions went everywhere. Now with Database functions, and the in-built TCPIP networking functions, I can create this idea:

THEORY

======

APP Login > TCP the server to check if user is valid

IF YES - TCP the server > Server return query using database vars > Send back to App > Copy into local database > Do whatever > Logout > Send database data back over TCP > Server copy into master database

IF NO - Close App

I'll write an _UpdateData UDF for inclusion.

Thanks, P. Callender

EDIT: Damn it, using Rich Edit features mean all line breaks are doubled (like @CR&@LF&@CR&@LF) for some reason.

Edited by Pa Callender

[size="4"]YOU SHALL NOT PARSE!![/size]

Share this post


Link to post
Share on other sites

works for me!

:)


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0