KenNichols Posted May 8, 2009 Share Posted May 8, 2009 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! CODEFunc _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! Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 8, 2009 Share Posted May 8, 2009 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 Link to comment Share on other sites More sharing options...
KenNichols Posted May 8, 2009 Author Share Posted May 8, 2009 I think you could test for $Tech.EOF to see if there are any records there.Thanks! I changed it toCODEFunc _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.CloseReturn $ResultEndIfEndFunc ;==> _Read [topic="21048"]New to AutoIt? Check out AutoIt 1-2-3![/topic] Need to make a GUI? You NEED KODA FormDesigner! 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