Sign in to follow this  
Followers 0
Idea

Simple SQL Error

9 posts in this topic

#1 ·  Posted (edited)

My .au3

#include <sql.au3>
Dim $oDBid
$oDBid=_SQLOpen("C:\mydb.mdb")
_SQLClose($oDBid)

If you could please point out how I can fix my simple script that would be great! I've tried a few things based on results found via the search option but nothing seems to work.

Example code (in AutoIt) for connecting to an Access database and adding values would be helpful, the posts I found via the search option are not working.

The error is:

Line 41 (File "C:\sql.au3"):
$o_ADOrs.Open ($s_DSN)
$o_ADOrs.Open ($s_DSN)^ERROR

Error: The requested action with this object has failed.

Edit: Removed the huge code file.

Edited by Idea

Share this post


Link to post
Share on other sites



maybe?:

#include <sql.au3>

$dbPath = "C:\mydb.mdb"

Dim $mydb,
$mydb=_SQLOpen("Driver={Microsoft Access Driver *.mdb)};Dbq=" & $dbPath & ";Uid=Admin;Pwd=;")
_SQLQuery($mydb, "INSERT INTO ppl (Name,Car,House) VALUES ('John Doe','red, 'free')")
SQLclose($mydb)

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

maybe?:

#include <sql.au3>

$dbPath = "C:\mydb.mdb"

Dim $mydb,
$mydb=_SQLOpen("Driver={Microsoft Access Driver *.mdb)};Dbq=" & $dbPath & ";Uid=Admin;Pwd=;")
_SQLQuery($mydb, "INSERT INTO ppl (Name,Car,House) VALUES ('John Doe','red, 'free')")
SQLclose($mydb)

<{POST_SNAPBACK}>

Thanks for the quick reply! I'm still getting the same error.

Update: Even with _SQLQuery commented out the error is still generated.

Edited by Idea

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks for the quick reply! I'm still getting the same error.

Update: Even with _SQLQuery commented out the error is still generated.

<{POST_SNAPBACK}>

Are you sure about this database string ? (see unbalanced red character)

"Driver={Microsoft Access Driver *.mdb)};Dbq=C:\mydb.mdb;Uid=Admin;Pwd=;"

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Are you sure about this database string ? (see unbalanced red character)

"Driver={Microsoft Access Driver *.mdb)};Dbq=C:\mydb.mdb;Uid=Admin;Pwd=;"

<{POST_SNAPBACK}>

Even with that remove the error is the same.

Just these four lines also generate the same error. I don't know how to fix it.

#include <sql.au3>
Dim $oDBid
$oDBid=_SQLOpen("C:\mydb.mdb")
_SQLClose($oDBid)

Example code (in AutoIt) for connecting to an Access database and adding values would be helpful. Thanks.

Edited by Idea

Share this post


Link to post
Share on other sites

Even with that remove the error is the same.

<{POST_SNAPBACK}>

What i find is that it should have the format :

"Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydb.mdb"

Example code (in AutoIt) for connecting to an Access database and adding values would be helpful. Thanks.

<{POST_SNAPBACK}>

It is not support by AutoIt standard functions or UDF's...

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I know the problem...i think...

you are using the syntax from the sql.au3 that I made, but a different sql.au3 file, mayve you just saw it in that post.

download my sql.au3 [link] and put it in your include directory, so replace i with whatever sql.au3 you have.

then again, it could be a completely different problem. but that syntax that you're using looks very simalar to mine ;)


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

I know the problem...i think...

you are using the syntax from the sql.au3 that I made, but a different sql.au3 file, mayve you just saw it in that post.

download my sql.au3 [link] and put it in your include directory, so replace i with whatever sql.au3 you have.

then again, it could be a completely different problem. but that syntax that you're using looks very simalar to mine ;)

<{POST_SNAPBACK}>

The function _SQLOpen isn't even included in the file you linked. The _SQLConnect function that is in there simply will not work with access as far as I can tell from testing. Thanks for yuor effort.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Here one of my common ways to connect to mdb files:

$oSa = ObjCreate("ADODB.Connection")
$oSa.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & @ScriptDir & "\mydb.mdb")
$oSa.Execute("INSERT INTO ppl (Name,Car,House) VALUES ('John Doe','red', 'free')")
$oSa.Close

Edit: Oops ... Found a typo in da code ... red was missing a closing '

Edited by sykes

We have enough youth. How about a fountain of SMART?

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