kepaha
(Fresh Scripter)
2005-06-16 09:36 PM
Opening RecordSet fails with WKIX32

I have finagled the following script (beginning with a sample found online) to write records to an Access db. I then call the KiX script from a batch file. If the batch file calls "\\server\path\kix32.exe \\path\script.kix", all is well. However, I prefer to use wkix32.exe and if I replace kix32 with wkix32 in the batch file, then the KiX script fails on the "$cmd.commandtext = $CMDtxt $rs.Open ($cmd)" line. Writing to screen, the error description is "COM exception error "Open" (ADODB.Recordset - The connection cannot be used to perform this operation. It is either closed or invalid in this context.) [-2147352567/80020009]". I cannot understand why this would work with KIX32 and not with WKIX32. Any insight ??? Thanks.

;====script====
$DBpath = "c:\hdtest.mdb"

$fullname = left(@fullname, INSTRREV(@fullname, " ") - 1)
$date = substr(@date, 6, 3) + substr(@date, 9, 2) + "/" + substr(@date, 1, 4)
$2 = @crlf + @crlf

color n/y+
At (3,2) " To send a request to the Help Desk type a brief "
At (4,2) " description of your question and then press Enter: " $2
color w/n
gets $Input

If $Input = ""
?"Please enter a description of your issue before pressing Enter:" + $2
gets $Input
EndIf

$Body = $input + $2 + $fullname
$CNstring = "provider=microsoft.jet.oledb.4.0;data source=$DBpath;persist security info=false"
$CMDtxt = "select * from TblCalls where 'CallUser' = 'Howitzer, Nanette'"
$cn = CreateObject ("ADODB.Connection")
$cmd = CreateObject ("ADODB.Command")
$rs = CreateObject ("ADODB.RecordSet")

$cn.connectionstring = $CNstring
$cn.Open
$cmd.activeconnection = $cn
$rs.cursortype = 3
$rs.locktype = 3
$rs.activecommand = $cmd

$cmd.commandtext = $CMDtxt $rs.Open ($cmd)

$rs.addnew
$rs.fields.item("CallUSA").value = "1"
$rs.fields.item("CallCategory").value = "10"
$rs.fields.item("CallDescription").value = $Body
$rs.fields.item("CallDate").value = $date
$rs.fields.item("CallUser").value = "10435"
$rs.update
$rs.Close


Kdyer
(KiX Supporter)
2005-06-16 10:04 PM
Re: Opening RecordSet fails with WKIX32

What version of KiX are we working with?

Have you been to - http://www.connectionstrings.com/ as there are a number of ways to connect to a database?

Kent


kepaha
(Fresh Scripter)
2005-06-16 10:08 PM
Re: Opening RecordSet fails with WKIX32

version 4.20. I have not been to that url, I will check it out.

maciep
(Korg Regular)
2005-06-17 04:47 PM
Re: Opening RecordSet fails with WKIX32

I have trouble believing it works with kix32.exe and not with wkix32.exe. Are you trying both from the same machine? If so, are you sure that it IS working with kix32.exe?

And what OS are you running it from? I've come across a that error on XP SP2 because the mdac has become corrupt - which requires a manual fix (reinstalling it doesn't appear to be allowed).


Les
(KiX Master)
2005-06-17 04:50 PM
Re: Opening RecordSet fails with WKIX32

Are you sure both KiX32.exe and WKiX32.exe are the same version? Have you tried a newer version?

kepaha
(Fresh Scripter)
2005-06-17 05:45 PM
Re: Opening RecordSet fails with WKIX32

Yes, both from the same machine. I am certain it is working with kix32. I check the db and the record is added. Running on XP, sp2. MDAC corruption would cause many other problems on this PC, so I don't think that is it.

Both kix32 and wkix32 are ver. 4.20. I tried it with 4.23, and it WORKS with both kix32 and wkix32.


NTDOCAdministrator
(KiX Master)
2005-06-17 06:33 PM
Re: Opening RecordSet fails with WKIX32

Well this is my guess

$fullname = left(@fullname, INSTRREV(@fullname, " ") - 1)


As I recall the -1 was not supported in v4.20
 


kepaha
(Fresh Scripter)
2005-06-17 06:46 PM
Re: Opening RecordSet fails with WKIX32

I remarked out the fullname line and the line where it is added as part of the body. Still, works with kix32 and does not work with wkix32.

NTDOCAdministrator
(KiX Master)
2005-06-17 09:21 PM
Re: Opening RecordSet fails with WKIX32

Well I can only surmise then that one of the many updates from 4.20 to 4.23 is involved. If you're unable to convert or upgrade to 4.23 or the upcoming 4.5 (hopefully early next week it will be released) then you're going to have to review all the code with a fine tooth comb and change the portion that is not working in 4.20

 


Les
(KiX Master)
2005-06-17 09:53 PM
Re: Opening RecordSet fails with WKIX32

Ja, not likely that Ruud will fix and re-release the 4.20 version of WKiX.

kepaha
(Fresh Scripter)
2005-06-18 12:19 AM
Re: Opening RecordSet fails with WKIX32

Ja, methinks we'll have to go to 4.23 or higher. Thanks for your assistance.

Sealeopard
(KiX Master)
2005-06-19 07:00 PM
Re: Opening RecordSet fails with WKIX32

You might also want to take a look at the UDF Forum under DBCommand() et al. before reinventing the wheel.