Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

please help me 1

Status
Not open for further replies.

Manic

Programmer
Feb 28, 2001
343
GB
I am as stuck as a stuck thing on stuck day.

Could someone have a look at the code to see what I have missed.

I need to get this done asap and I feel like crap.
code below (I have removed sone db connection stuff)
Cheers

Manic



<OptionExplicit>
<%@ LANGUAGE=&quot;VBSCRIPT&quot; %>
<% RESPONSE.BUFFER = TRUE %>

<%
Function WriteFile

DIM fileSys
DIM textStr
SET fileSys = Server.CreateObject (&quot;Scripting.FileSystemObject&quot;)
'file destination needs to be changed
Const saveFolder = &quot;C:\Inetpub\ 'file extention needs to be checked and add date to front of name
saveFile = &quot;BACSau.txt&quot;

If (NOT fileSys.FolderExists(saveFolder)) Then
fileSys.CreateFolder saveFolder
End If

Set textStr = fileSys.OpenTextFile(saveFolder+saveFile, 8, true)

textStr.WriteLine Sortcode & AccNo & Ammount & AccName & Reference & TransCode
textStr.Close

Set fileSys = Nothing
Set textStr = Nothing
%>

<% include file=&quot;adovbs.inc&quot; %>

<html><head><title>dd test</title></head><body>

<%
const adopenstatic = 3, adlockreadonly = 1, adcmdtext = &h0001

Dim CONN_STRING, CONN_USER, CONN_PASS ' database connection string
Dim myRs ' ADODB.Recordset Object
Dim myConn ' ADODB.Connection Object
Dim strSQL ' SQL string
Dim i

CONN_STRING = &quot;Provider=SQLOLEDB;Data Source=?;Database=?;UID=?;PWD=?&quot;

set myconn = server.createobject(&quot;adodb.connection&quot;)
set myrs = server.createobject(&quot;adodb.recordset&quot;)

myconn.open conn_string

strsql = &quot;select a.created as CreationDate,a.attrib_04 as PaymentType,a.attrib_06 as AccountName,floor(a.attrib_20) as SortCode,floor(a.attrib_21) as AccountNumber from s_org_ext_x a where a.attrib_04 = 'Direct Debit' and a.created >= '2001-01-25' and a.created < '2001-01-26'&quot;

myrs.open strsql, myconn, adopenstatic, adlockreadonly, adcmdtext

For i = 0 to myRs.Fields.Count -1 and CreationDate = DateValue(Now()) -1 & Attrib_04 = &quot;Direct Debit&quot;
response.WriteFile
next

if myrs.bof then
response.write &quot;no records found!&quot;
else
myrs.movefirst
end if

myrs.close
myconn.close

set myrs = nothing
set myconn = nothing

%>
</body></html> -----------------------------
I've broken it again !!
-----------------------------
 
Well, I see one thing, but I'm not sure it would cause an error. It would help if you told us what the error was, so we could know what we were looking for.

When you check for an empty recordset, though, you should use:
Code:
if myrs.bof and myrs.eof then 
    response.write &quot;no records found!&quot;
else
    myrs.movefirst
end if

Please post error messages so we can figure something else out.

:)
Paul Prewett
 
The original code would always show that no records were found, because I didn't see where you ever moved the recordset off the first record, and that's all you were checking for...

 
Error Type:
Microsoft VBScript compilation (0x800A03F6)
Expected 'End'
/ddtest/dd3.asp, line 67



line 67 is
set myconn = nothing

I have put in that other bit of code

Any Ideas -----------------------------
I've broken it again !!
-----------------------------
 
It looks to me like you declare a function (Function WriteFile), but there is no end function. That is why you are getting an &quot;expected End&quot; error. I am guessing that after
Code:
Set fileSys = Nothing
    Set textStr = Nothing
you simply need to add
Code:
End Function

I hope that helps.
 
thanks man.

you have saved my life.....

Where is the headache tablets

Manic -----------------------------
I've broken it again !!
-----------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top