Jump to content

Script for all database connections...


Raestlin
 Share

Recommended Posts

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
Link to comment
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.

Link to comment
Share on other sites

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

  • 2 weeks later...

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
Link to comment
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

Link to comment
Share on other sites

  • 3 weeks later...
  • 4 weeks later...

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

Link to comment
Share on other sites

  • 1 month later...

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]
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...