We help IT Professionals succeed at work.
Get Started

VB Script "Expected End of Statement"

Last Modified: 2012-08-13
Hi Experts,

I am using the following code and it telling me there is an error on Line 1 indicating Expected end of Statement.

I have also tried seperating the Dim's at the start to read something like:

Dim n, nTotal  
Dim cnn, rst

but that did not work either.

Never used VB Script before but after doing my home work I have found there should be nothing wrong with the code.

Can anyone see any problems in the code below.
Dim n, nTotal  Dim cnn, rst
    Set cnn = CreateObject("ADODB.Connection")
    Set rst = CreateObject("ADODB.Recordset")

strPathtoTextFile = "C:\Databases"

    cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
          "Data Source=" & strPathtoTextFile & ";" & _
          "Extended Properties=""text;HDR=YES;FMT=Delimited"""
    rst.Open "SELECT * FROM accounts.csv WHERE client_id=" 
         &  CInt(mailer.fields("client_id")), cnn
    n = 1
    nTotal = 0
    Do Until rst.EOF
        mailer.write("invoice" & n & ", ")
        mailer.write(rst("totalamount1") & ", ")
        if Len(rst("attach")) > 0 then mailer.attachFile(rst("attach"))
        n = n + 1
        nTotal = nTotal + rst("amount")

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 20 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE