Solving a Mystery About 'BC30205: End of statement expected'

A reader of my book ran into the strangest problem that had me going around in circles. He was working through one of the ASP.NET 3.5 examples in Visual Web Developer 2008 and was getting weird errors like these:

error BC30205: End of statement expected.
error BC30451: Name 'q' is not declared.
error BC30451: Name 'itm' is not declared

The reader had entered the VB code and markup exactly as required (using the single page model). Even dropping my working .aspx file into his site still caused the errors. Why?

After downloading the complete chapter code, the reader noticed the key difference - his site didn't have a Web.config file! Without a web.config file, the VB compiler just doesn't know what to do. Everything is wrong at that point and the IDE laces the code with squiggles.

Why didn't he have a web.config file? Well, if you choose the 'Empty Web Site' option in VWD 2008, that's what you get - an empty web site without a web.config.

What makes this strange is that my example code included a web.config file. My best guess is that one of those VWD wizards such as Configure Data Source (SqlDataSource) needs to store stuff in a web.config file.  If it doesn't find one, it silently adds it and goes about its business. Not all designers provide this service, so the existence of a web.config can be hit and miss - if you've used the Empty Web Site option.

Anyway, I've marked this as a bug (errata) in the book. The moral of the story is that your code can be perfect but unless the configuration tells the compiler what to expect, you'll get misleading error messages like 'error BC30205: End of statement expected. '

Ken

Published Thursday, November 27, 2008 12:28 AM by Ken Cox [MVP]
Filed under: , ,

Comments

# Solving a Mystery About 'BC30205: End of statement expected' - WebLog of Ken Cox

Pingback from  Solving a Mystery About 'BC30205: End of statement expected' - WebLog of Ken Cox

# problem solving skills | AMD.com

Thursday, November 27, 2008 2:27 PM by problem solving skills | AMD.com

Pingback from  problem solving skills | AMD.com

# re: Solving a Mystery About 'BC30205: End of statement expected'

Friday, January 09, 2009 4:39 PM by Safe ASSET

yeah im having that problem aswell. But i have no idea how to get around it.

# re: Solving a Mystery About 'BC30205: End of statement expected'

Wednesday, March 18, 2009 4:24 PM by David

I DO have a web.config file, and the ASP.NET project is set for .NET 3.5. I still get this error.

# re: Solving a Mystery About 'BC30205: End of statement expected'

Saturday, November 20, 2010 3:26 PM by utpal-ur best pal

I too am getting End of Statement Required Error

Error Line:

Dim MySQL As String = "INSERT INTO Contact Us (Name, Company) VALUES ('" & TextBox1.Text & "')" "('" & TextBox4.Text & "')"

Entire Code:

<script runat="server">

   Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

       Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath("sociomarker.mdb") & ";"

      Dim MySQL As String = "INSERT INTO Contact Us (Name, Company) VALUES ('" & TextBox1.Text & "')" "('" & TextBox4.Text & "')"

      Dim MyConn As New OleDbConnection(strConn)

       Dim cmd As New OleDbCommand(MSQL, MyConn)

      MyConn.Open()

      cmd.ExecuteNonQuery()

      MyConn.Close()

       Response.Redirect("index.html")

   End Sub

   </script>

Kindly assist me with this.

Thanks and Regards

Leave a Comment

(required) 
(required) 
(optional)
(required)