aquila Posted November 29, 2008 Share Posted November 29, 2008 Hello guys. I have an access Database, and I want to read out the values. -> http://img397.imageshack.us/my.php?image=accessdbvb1.jpgThe Code says The requested action with this object has failed.What could be the problem? I already tested other udfs and functions from this forum here, but they don't work, too. Same Probs...$dbname = "C:\a.mdb" $tblname = "User" $fldname = "UserName" $query = "SELECT * FROM "& $tblname & " WHERE UserName = " & "'aquila'" ; hier wird der abfragestring aus den variablen zusammengesetzt ( zeige mir alle aus tabelle xy wo der wert der spalte feld01 = der ;username ist ), dieser wert, falls in der tabelle vorhanden steht dann in der variable "$query" $strData1 = _ReadOneFld($query, $dbname, $fldname) ; liest wert "feld01" in die variable $strData1 ;~ $strData2 = _ReadOneFld($query, $dbname, $fldname1); liest wert "feld02" in die variable $strData2 Func _ReadOneFld($_sql, $_dbname, $_field) Dim $_output $adoCon = ObjCreate ("ADODB.Connection") $adoCon.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $_dbname) $adoRs = ObjCreate ("ADODB.Recordset") $adoRs.CursorType = 1 $adoRs.LockType = 3 $adoRs.Open ($_sql, $adoCon) With $adoRs If .RecordCount Then While Not .EOF $_output = $_output & .Fields ($_field).Value & @CRLF .MoveNext WEnd EndIf EndWith $adoCon.Close Return $_output EndFunc ;==>_ReadOneFld Link to comment Share on other sites More sharing options...
Developers Jos Posted November 29, 2008 Developers Share Posted November 29, 2008 Have a go with this code: Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $dbname = "C:\a.mdb" $tblname = "User" $fldname = "UserName" $query = "SELECT * FROM " & $tblname & " WHERE UserName = 'aquila'" ; hier wird der abfragestring aus den variablen zusammengesetzt ( zeige mir alle aus tabelle xy wo der wert der spalte feld01 = der ;username ist ), dieser wert, falls in der tabelle vorhanden steht dann in der variable "$query" $strData1 = _ReadOneFld($query, $dbname, $fldname); liest wert "feld01" in die variable $strData1 ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $strData1 = ' & $strData1 & @crlf & '>Error code: ' & @error & @crlf);### Debug Console ;~ $strData2 = _ReadOneFld($query, $dbname, $fldname1); liest wert "feld02" in die variable $strData2 Func _ReadOneFld($_sql, $_dbname, $_field) Dim $_output $adoCon = ObjCreate("ADODB.Connection") $adoCon.Open("Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & $_dbname) $adoRs = $adoCon.Execute($_sql) While Not $adoRs.EOF $_output = $_output & $adoRs.fields("Username").value & @CRLF $adoRs.MoveNext WEnd $adoCon.Close Return $_output EndFunc ;==>_ReadOneFld ; ; ; Com Error Handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description, 3) ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF) SetError(1); something to check for when this function returns Return EndFunc ;==>MyErrFunc Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
aquila Posted November 29, 2008 Author Share Posted November 29, 2008 (edited) Hej Jos Wow, thanks for that help! But I still get an error (translated, cause it's a german error ): Error ! Number: 80020009 ScriptLine: 16 Description:[Microsoft][ODBC Microsoft Access Driver] The sorting sequence is not supported by the operationg system. I am using XP Sp2. *Edit: It's a MS 2000 Access database. I don't know what i can do Edited November 29, 2008 by aquila Link to comment Share on other sites More sharing options...
Developers Jos Posted November 29, 2008 Developers Share Posted November 29, 2008 The script I posted works for me on a ms 2000 access test database i made. Can you attach a small test database that will show this error when running the script ? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
aquila Posted November 29, 2008 Author Share Posted November 29, 2008 (edited) Hey Jos. You are right! Something was strange with that db. It works now ! <3 you But I have another question. Hope you can help me. If it finds the name it will give out the name. Can I read out both, the Password and the Name?http://img444.imageshack.us/my.php?image=dbaccessns7.jpgEdit: Ah, got it myself $_output = $_output & $adoRs.fields("Username").value & $adoRs.fields("Password").value & @CRLF Edited November 29, 2008 by aquila Link to comment Share on other sites More sharing options...
Developers Jos Posted November 29, 2008 Developers Share Posted November 29, 2008 (edited) There is a set of Access udf's created by Geosoft (George) that you could use to,It has a pretty comprehensive set of functions you could look at a learn from.Just search for access.au3 in the examples forum. here is a link to it: http://www.autoitscript.com/forum/index.ph...p;hl=access.au3Jos Edited November 29, 2008 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now