Can you help me with this code? It's really urgent. Thank You. Miguel

  • Thread starter Thread starter Miguel Dias Moura
  • Start date Start date
M

Miguel Dias Moura

Hello,

i am having some problems in a code which populates an ASP.net Calendar
control with events taken from an Access Database. I have this working in C#
but i am getting some errors in VB.
I need to have this done until tomorrow because i will have a flight then.
Can you help me?

You can download the .zip file in: www.27lamps.com/tzone/calendar.zip

Thank You Very Much,
Miguel

The errors i am getting when i run the events.aspx page are:

Microsoft (R) Visual Basic .NET Compiler version 7.10.3052.4
for Microsoft (R) .NET Framework version 1.1.4322.573
Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.

....events.aspx(27) : error BC32017: Comma, ')', or a valid expression
continuation expected.

strEvents.Append("<span style=\"font-size:80%\">")
~~~~
....events.aspx(27) : error BC30035: Syntax error.

strEvents.Append("<span style=\"font-size:80%\">")
~~~
....events.aspx(31) : error BC30689: Statement cannot appear outside of a
method body.

For Each Row As DataRow In ds.Tables.Item("events").Rows
~~~

....events.aspx(32) : error BC30451: Name 'row' is not declared.

Dim eventdate As DateTime = row.Item("eventdate")
~~~
....events.aspx(33) : error BC30689: Statement cannot appear outside of a
method body.

If eventdate.Equals(E.Day.Date) Then
~~
....events.aspx(34) : error BC30188: Declaration expected.

strEvents.Append("<br />" & row.Item("eventdate"))
~~~~~~~~~
....events.aspx(35) : error BC30087: 'End If' must be preceded by a matching
'If'.

End If
~~~~~~
....events.aspx(37) : error BC30188: Declaration expected.

strEvents.Append("</span>")
~~~~~~~~~
....events.aspx(39) : error BC30188: Declaration expected.

E.Cell.Controls.Add(New LiteralControl(strEvents.ToString()))
~
....events.aspx(40) : error BC30035: Syntax error.

Next
 
The escape character you are using for your quotes is C# specific. Use ""
instead of \".
 
FYI, with the mass amounts of viruses in ZIP's people aren't likely to dload
this.

Post the errors one at a time, with the corresponding code line(s).
 
Hello,

if someone wants i can send the files with .zip or no .zip to an email
address.
Anyway, the errors i get and the code lines for each error are:

Error: error BC32017: Comma, ')', or a valid expression continuation
expected.
Code: strEvents.Append("<span style=\"font-size:80%\">")

Error: error BC30035: Syntax error.
Code: strEvents.Append("<span style=\"font-size:80%\">")

Error: error BC30689: Statement cannot appear outside of a method body.
Code: For Each Row As DataRow In ds.Tables.Item("events").Rows

Error: error BC30451: Name 'row' is not declared.
Code: Dim eventdate As DateTime = row.Item("eventdate")

Error: error BC30689: Statement cannot appear outside of a method body.
Code: If eventdate.Equals(E.Day.Date) Then

Error: error BC30188: Declaration expected.
Code: strEvents.Append("<br />" & row.Item("eventdate"))

Error: error BC30087: 'End If' must be preceded by a matching 'If'.
Code: End If

Error: error BC30188: Declaration expected.
Code: strEvents.Append("</span>")

Error: error BC30188: Declaration expected.
Code: E.Cell.Controls.Add(New LiteralControl(strEvents.ToString()))

Error: C:\Inetpub\wwwroot\calendarVB\events.aspx(40) : error BC30035: Syntax
error.
Code: Next

Thank You,
Miguel
 
And all the code of page events.aspx is the following:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Page Language="VB" Debug="True" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Xml" %>

<script runat="server">
Dim ds as New DataSet

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim StrConn as String =
"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=Server.MapPath('aspnet_calendar
..mdb')"
Dim da as OleDbDataAdapter
Dim strSQL = "SELECT * FROM events"
Dim Conn as New OleDbConnection(StrConn)

Conn.Open()
da = New OleDbDataAdapter(strSQL, Conn)
da.Fill(ds, "events")
Conn.Close()

End Sub

Private Sub eventscalendar_DayRender (src As Object, E As
DayRenderEventArgs)

Dim strEvents as New StringBuilder()
strEvents.Append("<span style=\"font-size:80%\">")

End Sub

For Each Row As DataRow In ds.Tables.Item("events").Rows
Dim eventdate As DateTime = row.Item("eventdate")
If eventdate.Equals(E.Day.Date) Then
strEvents.Append("<br />" & row.Item("eventdate"))
End If
'Close off the string in the strEvents StringBuilder
strEvents.Append("</span>")
'Add the string to the cell in a LiteralControl
E.Cell.Controls.Add(New LiteralControl(strEvents.ToString()))
Next

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Event Calendar</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<form runat="server">
<asp:calendar DayStyle-HorizontalAlign="right" ID="eventcalendar"
runat="server" ShowGridLines="true"
OnDayRender="eventscalendar_DayRender"></asp:calendar>
</form>

</body>
</html>

It might be usefull.

Thank You,
Miguel
 
Back
Top