Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

spitfire2903

calendario em asp

Recommended Posts

Eu peguei um script de calendario e tentei adicionar um banco de dados para colocar eventos, só que eu adiciono evento e o evento nao aparece no calendario. Outro problema tambem é que se eu digitar o endereço com as strings e tudo mais, nao carrega da erro: "ADODB.Field error '80020009'Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. "São duas paginas os codigos estao abaixo: ## calendar.asp

<%cnpath="DBQ=" & Server.MapPath("calendario.mdb") DataSource = "Driver={Microsoft Access Driver (*.mdb)}; " & cnpath Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open DataSource'*******************************************************'* ASP 101 Sample Code - http://www.asp101.com *'* *'* This code is made available as a service to our *'* visitors and is provided strictly for the *'* purpose of illustration. *'* *'* Please direct all inquiries to webmaster@asp101.com *'*******************************************************' ***Begin Function Declaration***' New and improved GetDaysInMonth implementation.' Thanks to Florent Renucci for pointing out that I' could easily use the same method I used for the' revised GetWeekdayMonthStartsOn function.Function GetDaysInMonth(iMonth, iYear) Dim dTemp dTemp = DateAdd("d", -1, DateSerial(iYear, iMonth + 1, 1)) GetDaysInMonth = Day(dTemp)End Function' Previous implementation on GetDaysInMonth'Function GetDaysInMonth(iMonth, iYear)' Select Case iMonth' Case 1, 3, 5, 7, 8, 10, 12' GetDaysInMonth = 31' Case 4, 6, 9, 11' GetDaysInMonth = 30' Case 2' If IsDate("February 29, " & iYear) Then' GetDaysInMonth = 29' Else' GetDaysInMonth = 28' End If' End Select'End FunctionFunction GetWeekdayMonthStartsOn(dAnyDayInTheMonth) Dim dTemp dTemp = DateAdd("d", -(Day(dAnyDayInTheMonth) - 1), dAnyDayInTheMonth) GetWeekdayMonthStartsOn = WeekDay(dTemp)End FunctionFunction SubtractOneMonth(dDate) SubtractOneMonth = DateAdd("m", -1, dDate)End FunctionFunction AddOneMonth(dDate) AddOneMonth = DateAdd("m", 1, dDate)End Function' ***End Function Declaration***Dim dDate ' Date we're displaying calendar forDim iDIM ' Days In MonthDim iDOW ' Day Of Week that month starts onDim iCurrent ' Variable we use to hold current day of month as we write tableDim iPosition ' Variable we use to hold current position in table' Get selected date. There are two ways to do this.' First check if we were passed a full date in RQS("date").' If so use it, if not look for seperate variables, putting them togeter into a date.' Lastly check if the date is valid...if not use todayIf IsDate(Request.QueryString("date")) Then dDate = CDate(Request.QueryString("date"))Else If IsDate(Request.QueryString("month") & "-" & Request.QueryString("day") & "-" & Request.QueryString("year")) Then dDate = CDate(Request.QueryString("month") & "-" & Request.QueryString("day") & "-" & Request.QueryString("year")) Else dDate = Date() ' The annoyingly bad solution for those of you running IIS3 If Len(Request.QueryString("month")) <> 0 Or Len(Request.QueryString("day")) <> 0 Or Len(Request.QueryString("year")) <> 0 Or Len(Request.QueryString("date")) <> 0 Then Response.Write "A data que você escolheu não é valida..<BR><BR>" End If ' The elegant solution for those of you running IIS4 'If Request.QueryString.Count <> 0 Then Response.Write "The date you picked was not a valid date. The calendar was set to today's date.<BR><BR>" End IfEnd If'Now we've got the date. Now get Days in the choosen month and the day of the week it starts on.iDIM = GetDaysInMonth(Month(dDate), Year(dDate))iDOW = GetWeekdayMonthStartsOn(dDate)%><!-- Outer Table is simply to get the pretty border--><body background="fundo.jpg"><TABLE BORDER=6 align="center" CELLPADDING=0 CELLSPACING=0><TR><TD><TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 BGCOLOR=#99CCFF> <TR> <TD BGCOLOR=#000099 ALIGN="center" COLSPAN=7> <TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0> <TR> <TD ALIGN="right"><A HREF="./calendar.asp?date=<%= SubtractOneMonth(dDate) %>"><FONT COLOR=#FFFF00 SIZE="-1"><<</FONT></A></TD> <TD ALIGN="center"><FONT COLOR=#FFFF00><B><%= MonthName(Month(dDate)) & " " & Year(dDate) %></B></FONT></TD> <TD ALIGN="left"><A HREF="./calendar.asp?date=<%= AddOneMonth(dDate) %>"><FONT COLOR=#FFFF00 SIZE="-1">>></FONT></A></TD> </TR> </TABLE> </TD> </TR> <TR> <TD ALIGN="center" BGCOLOR=#0000CC><b><font color="#FFFF00">Dom</font></b><BR> <IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD> <TD ALIGN="center" BGCOLOR=#0000CC><FONT COLOR=#FFFF00><B>Seg</B></FONT><BR> <IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD> <TD ALIGN="center" BGCOLOR=#0000CC><FONT COLOR=#FFFF00><B>Ter</B></FONT><BR> <IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD> <TD ALIGN="center" BGCOLOR=#0000CC><FONT COLOR=#FFFF00><B>Qua</B></FONT><BR> <IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD> <TD ALIGN="center" BGCOLOR=#0000CC><b><font color="#FFFF00">Qui</font></b><BR> <IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD> <TD ALIGN="center" BGCOLOR=#0000CC><b><font color="#FFFF00">---</font></b><BR> <IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD> <TD ALIGN="center" BGCOLOR=#0000CC><FONT COLOR=#FFFF00><B>Sab</B></FONT><BR> <IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD> </TR><%' Write spacer cells at beginning of first row if month doesn't start on a Sunday.If iDOW <> 1 Then Response.Write vbTab & "<TR>" & vbCrLf iPosition = 1 Do While iPosition < iDOW Response.Write vbTab & vbTab & "<TD> </TD>" & vbCrLf iPosition = iPosition + 1 LoopEnd If' Write days of month in proper day slotsiCurrent = 1iPosition = iDOWDo While iCurrent <= iDIM ' If we're at the begginning of a row then write TR If iPosition = 1 Then Response.Write vbTab & "<TR>" & vbCrLf End If ' If the day we're writing is the selected day then highlight it somehow. If iCurrent = Day(dDate) Then edate = iCurrent & "-" & Month(dDate) & "-" & Year(dDate) set rs=conn.execute("select * from calendario where data=" & edate & " ") Response.Write vbTab & vbTab & "<TD BGCOLOR=#00FFFF><FONT SIZE=""-1""><B>" & iCurrent & "</B></FONT><BR>" If rs.EOF Then Response.Write " " Else Response.Write "<A HREF=""cal.asp?id=" & rs("id") & "&data=" & edate & """>" & rs("abrev") & "</a>" End If Response.Write "<BR></TD>" & vbCrLf Else edate = iCurrent & "-" & Month(dDate) & "-" & Year(dDate) set rs=conn.execute("select * from calendario where data=" & edate & " ") Response.Write vbTab & vbTab & "<TD><FONT SIZE=""-1"">" & iCurrent & "</FONT><BR>" If rs.EOF Then Response.Write " " Else Response.Write "<A HREF=""cal.asp?id=" & rs("id") & "&data=" & edate &""">" & rs("abrev") & "</a>" End If Response.Write "<BR></TD>" & vbCrLf End If ' If we're at the endof a row then write /TR If iPosition = 7 Then Response.Write vbTab & "</TR>" & vbCrLf iPosition = 0 End If ' Increment variables iCurrent = iCurrent + 1 iPosition = iPosition + 1Loop' Write spacer cells at end of last row if month doesn't end on a Saturday.If iPosition <> 1 Then Do While iPosition <= 7 Response.Write vbTab & vbTab & "<TD> </TD>" & vbCrLf iPosition = iPosition + 1 Loop Response.Write vbTab & "</TR>" & vbCrLfEnd If%></TABLE></TD></TR></TABLE><BR><TABLE BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0> <TR><TD ALIGN="center"><FORM ACTION="./calendar.asp" METHOD=GET><SELECT NAME="month"> <OPTION VALUE=1>Janeiro</OPTION> <OPTION VALUE=2>Fevereiro</OPTION> <OPTION VALUE=3>Março</OPTION> <OPTION VALUE=4>Abril</OPTION> <OPTION VALUE=5>Maio</OPTION> <OPTION VALUE=6>Junho</OPTION> <OPTION VALUE=7>Julho</OPTION> <OPTION VALUE=8>Agosto</OPTION> <OPTION VALUE=9>Setembro</OPTION> <OPTION VALUE=10>Outubro</OPTION> <OPTION VALUE=11>Novembro</OPTION> <OPTION VALUE=12>Dezembro</OPTION></SELECT><SELECT NAME="day"> <OPTION VALUE=1>1</OPTION> <OPTION VALUE=2>2</OPTION> <OPTION VALUE=3>3</OPTION> <OPTION VALUE=4>4</OPTION> <OPTION VALUE=5>5</OPTION> <OPTION VALUE=6>6</OPTION> <OPTION VALUE=7>7</OPTION> <OPTION VALUE=8>8</OPTION> <OPTION VALUE=9>9</OPTION> <OPTION VALUE=10>10</OPTION> <OPTION VALUE=11>11</OPTION> <OPTION VALUE=12>12</OPTION> <OPTION VALUE=13>13</OPTION> <OPTION VALUE=14>14</OPTION> <OPTION VALUE=15>15</OPTION> <OPTION VALUE=16>16</OPTION> <OPTION VALUE=17>17</OPTION> <OPTION VALUE=18>18</OPTION> <OPTION VALUE=19>19</OPTION> <OPTION VALUE=20>20</OPTION> <OPTION VALUE=21>21</OPTION> <OPTION VALUE=22>22</OPTION> <OPTION VALUE=23>23</OPTION> <OPTION VALUE=24>24</OPTION> <OPTION VALUE=25>25</OPTION> <OPTION VALUE=26>26</OPTION> <OPTION VALUE=27>27</OPTION> <OPTION VALUE=28>28</OPTION> <OPTION VALUE=29>29</OPTION> <OPTION VALUE=30>30</OPTION> <OPTION VALUE=31>31</OPTION></SELECT><SELECT NAME="year"> <OPTION VALUE=2006>2006</OPTION> <OPTION VALUE=2007 selected>2007</OPTION> <OPTION VALUE=2008>2008</OPTION> <OPTION VALUE=2009>2009</OPTION> <OPTION VALUE=2010>2010</OPTION> <OPTION VALUE=2011>2011</OPTION> <OPTION VALUE=2012>2012</OPTION> <OPTION VALUE=2013>2013</OPTION> <OPTION VALUE=2014>2014</OPTION></SELECT><BR><INPUT TYPE="submit" VALUE="Mostrar essa data no calendario!"></FORM></TD></TR></TABLE>

## cal.asp

<%cnpath="DBQ=" & Server.MapPath("calendario.mdb") DataSource = "Driver={Microsoft Access Driver (*.mdb)}; " & cnpath Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open DataSourceset rs=conn.execute("select * from calendario where data=" & Request.QueryString("data") & " ")%><!-- Outer Table is simply to get the pretty border--><style type="text/css"><!--body { background-image: url(fundo.jpg);}.style2 {font-size: 18px}--></style><table width="354" height="171" border="0" align="center" cellspacing="0"> <tr bgcolor="#000066"> <td height="37" colspan="2" align="center"><span class="style2"><font color="#FFFFFF"><strong><%=rs("evento")%><strong></font></span></td> </tr> <tr bgcolor="#6699FF"> <td height="29" colspan="2" align="center"><strong>Dia <%=rs("data")%></strong></td> </tr> <tr bgcolor="#FFFF99"> <td width="85" height="27"><div align="right"><strong>Local:</strong></div></td> <td width="262"><%=rs("local")%></td> </tr> <tr bgcolor="#FFFF99"> <td height="27"><div align="right"><strong>Horário:</strong></div></td> <td><%=rs("hora")%></td> </tr> <tr bgcolor="#FFFF99"> <td colspan="2"><%=rs("descricao")%></td> </tr></table><p> </p><p> </p>

Link para download:Download

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá!!Assim fica um pouco "dificil" de entender o seu código.Mais vamos por parte..1º - Você disse que está funcionando o calendário, ok ;) ??2º - Já que você "pegou" o código da internet, será que não consegue achar um que contenha cadastro de eventos.No mais, tente dividir o código por "ações" para que possamos ajuda-lo!!Até

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.