Sign in to follow this  
Followers 0
KenNichols

Need Help with mbd Function

3 posts in this topic

If $Tech.Fields ($fldname2).Value Does not exist I get an Error! It works great if a value is there. I have tried to fix this 20 different ways and I just don't understand enough to figure this out!

CODE
Func _Read($dbname,$tblname,$fldname1,$fldname2,$data1)

$adoCon = ObjCreate ("ADODB.Connection")

$adoCon.Open ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $dbname & ";")

$query = "SELECT * FROM " & $tblname & " WHERE " & $fldname1 & '="' & $data1 & '"'

$Tech = $adoCon.Execute($query)

$Result = $Tech.Fields ($fldname2).Value

$adoCon.Close

Return $Result

EndFunc ;==> _Read


[topic="21048"]New to AutoIt? Check out AutoIt 1-2-3![/topic] Need to make a GUI? You NEED KODA FormDesigner!

Share this post


Link to post
Share on other sites



If $Tech.Fields ($fldname2).Value Does not exist I get an Error! It works great if a value is there. I have tried to fix this 20 different ways and I just don't understand enough to figure this out!

Func _Read($dbname,$tblname,$fldname1,$fldname2,$data1)
$adoCon = ObjCreate ("ADODB.Connection")
$adoCon.Open ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $dbname & ";")
    $query = "SELECT * FROM " & $tblname & " WHERE " & $fldname1 & '="' & $data1 & '"'
$Tech = $adoCon.Execute($query)
$Result = $Tech.Fields ($fldname2).Value
$adoCon.Close
Return $Result
EndFunc ;==> _Read
I think you could test for $Tech.EOF to see if there are any records there.

^_^


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I think you could test for $Tech.EOF to see if there are any records there.

Thanks! I changed it to

CODE
Func _Read($dbname,$tblname,$fldname1,$fldname2,$data1)

$adoCon = ObjCreate ("ADODB.Connection")

$adoCon.Open ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $dbname & ";")

$query = "SELECT * FROM " & $tblname & " WHERE " & $fldname1 & '="' & $data1 & '"'

$Tech = $adoCon.Execute($query)

If $Tech.EOF Then

$adoCon.Close

$Result = ""

;MsgBox(1,"Error", "Tech ID: " & $data1 & " does not exist")

Return $Result

Else

$Result = $Tech.Fields ($fldname2).Value

$adoCon.Close

Return $Result

EndIf

EndFunc ;==> _Read


[topic="21048"]New to AutoIt? Check out AutoIt 1-2-3![/topic] Need to make a GUI? You NEED KODA FormDesigner!

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