Ir para conteúdo
  • ×   Você colou conteúdo com formatação.   Remover formatação

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

  • Conteúdo Similar

    • Por marcelocardoso
      Galera...

      Estou tentando conectar banco de dados MySQL, tenho a instrução abaixo, porém, não consigo EXIBIR os dados, como se o banco não conectasse ou não estivesse ativo:
      CODIGO:
      <% servidor = "localhost" banco = "db_verdesmares" usuario = "root" senha = "marmmc" porta = "3307" opcao = "3" provedor = "DRIVER={MYSQL ODBC 5.3 UNICODE Driver};SERVER="&servidor&";PORT="&porta&";DATABASE="&banco&";UID="&usuario&";PWD="&senha&";OPTION="&opcao&";" SET cnnDB = Server.CreateObject("ADODB.Connection") cnnDB.Open provedor SET strRS = Server.CreateObject("ADODB.Recordset") strRS.Open "SELECT * FROM vm_noticias ORDER BY id DESC", cnnDB response.write "conectou ao banco sem problemas, pois passou por aqui.." response.write provedor DO WHILE NOT strRS.EOF %> <div class="row" style="padding-bottom: 15px; padding-top: 15px;"> <div id="noticia_data" class="text-center"><%=strRS("vmares_data")%></div> <div class="col-md-12"> <p style="font-size: 22px;"><%=strRS("vmares_titulo")%></p> </div> <div class="col-md-12 text-muted"><%=strRS("vmares_descricao")%> </div> <div id="noticia_link" class="col-md-12 pull-right">+ detalhes</div> <% strRS.MoveNext Loop response.write "passou pelo laço, funcionou..." %> Acredito que meu código está correto, só se não estou enchergando algo que pode estar errado.
      Se conseguirem me dar uma luz, seria ótimo..

      Tentei trocar o DRIVER 5.3 para ANSI e UNICODE, porém de nenhum jeito vai.
      Tentei criar um DSN pelo ODBC também não...

      Ajuda, agradeço.
      Obrigado.
    • Por FabianoSouza
      Encontrei esse código para gerar calendário e estou adaptando para meu uso.
       
      O problema está na hora de percorrer um recordset e exibir os compromissos dentro das TD da tabela.
      Quando há dois ou mais compromissos na mesma data, o loop falha, deixando de escrever os compromissos de outras datas.
      Mas se houver apenas 1 compromisso por dia, funciona direitinho.
       
      Ilustrando:
      Isso funciona
      Compromisso A - 10/07/2017
      Compromisso B - 15/07/2017
      Compromisso C - 18/07/2017
       
      Isso não funciona
      Compromisso A - 10/07/2017
      Compromisso B - 15/07/2017
      Compromisso C - 15/07/2017
       
       
      Esse trecho é responsável por escrever o compromisso dentro da TD
       
      Dim meuDia, meuMes, meuAno meuDia = Day(rs("Inicio")) meuMes = Month(rs("Inicio")) meuAno = Year(rs("Inicio")) If meuDia = Day(dtCurViewDay) AND meuMes = Month(dtCurViewDay) AND meuAno = Year(dtCurViewDay) Then Response.Write "<span>" & rs("DatasDescricao") & "</span>" rs.Movenext End if Suspeito que o problema esteja na linha "rs.Movebext". Talvez eu não esteja movimentando o RS no lugar correto do código.
       
      Agora o código na íntegra (lembrando que estou adaptando o código, não criei do zero, tem umas functions que não sei pra que servem).
      <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <%Option Explicit%> <% Function FormatStr(String) on Error resume next String = Replace(String, CHR(13), "") String = Replace(String, CHR(10) & CHR(10), "</P><P>") String = Replace(String, CHR(10), "<BR>") FormatStr = String End Function Dim dtToday dtToday = Date() Dim dtCurViewMonth ' First day of the currently viewed month Dim dtCurViewDay ' Current day of the currently viewed month Dim frmDate ' Date submitted by form ' if the GO button was used, build the date from the month and year If InStr(1, Request.Form, "subGO", 1) > 0 then if Request.Form("CURDATE_month") = "" then tmpMonth = month(now()) else tmpMonth = Request.Form("CURDATE_month") End If if Request.Form("CURDATE_year") = "" then tmpyear = year(now()) else tmpyear = Request.Form("CURDATE_year") End If tmpDate = "1 " & tmpMonth & " 1999" mnth = Month(tmpDate) frmDate = DateSerial(tmpyear, mnth, 1) Else frmDate = Request.Form("CURDATE") end if if Request("view_date") <> "" then frmDate= DateSerial(year(Request("view_date")), month(Request("view_date")), 1) end if %> <% REM This section defines functions to be used later on. %> <% REM This sets the Previous Sunday and the Current Month %> <% '-------------------------------------------------- Function DtPrevSunday(ByVal dt) Do While WeekDay(dt) > vbSunday dt = DateAdd("d", -1, dt) Loop DtPrevSunday = dt End Function '-------------------------------------------------- %> <%REM Set current view month from posted CURDATE, or ' the current date as appropriate. ' if posted from the form ' if prev button was hit on the form If InStr(1, Request.Form, "subPrev", 1) > 0 Then dtCurViewMonth = DateAdd("m", -1, frmDate) ' if next button was hit on the form ElseIf InStr(1, Request.Form, "subNext", 1) > 0 Then dtCurViewMonth = DateAdd("m", 1, frmDate) ' anyother time Else ' date add in text box If InStr(1, Request.Form, "subGO", 1) > 0 then dtCurViewMonth = frmDate Else if Request("view_date") <> "" then dtCurviewMonth = frmDate else dtCurViewMonth = DateSerial(Year(dtToday), Month(dtToday), 1) End If End If End If %> <% '--------BEGINNING OF DRAW CALENDAR SECTION-------- %> <% Dim iDay, iWeek, sFontColor, dictDte(31,2), intCount Dim strSql, rs strSQL = "" strSQL = "SELECT " strSQL = strSQL &"CONVERT(VARCHAR(10), DatasDataInicio, 103) AS 'Inicio'" strSQL = strSQL &", DatasDescricao " strSQL = strSQL &" FROM tabDatas " strSQL = strSQL &" WHERE " strSQL = strSQL &" MONTH(DatasDataInicio) = DATEADD(DD,-1,MONTH(GETDATE()))" strSQL = strSQL &" AND" strSQL = strSQL &" YEAR(DatasDataInicio) = YEAR(GETDATE())" strSQL = strSQL &" OR " strSQL = strSQL &" MONTH(DatasDataInicio) = MONTH(GETDATE())" strSQL = strSQL &" AND " strSQL = strSQL &" YEAR(DatasDataInicio) = YEAR(GETDATE())" strSQL = strSQL &" OR" strSQL = strSQL &" MONTH(DatasDataInicio) = DATEADD(DD,+1,MONTH(GETDATE()))" strSQL = strSQL &" AND " strSQL = strSQL &" YEAR(DatasDataInicio) = YEAR(GETDATE())" strSQL = strSQL &" ORDER BY " strSQL = strSQL &" DatasDataInicio " strSQL = strSQL &" ASC" set rs = conexao.Execute (strSql) intCount= 0 ' populate array with days of month on Error resume next ' do until rs.EOF ' if intCount > 31 then exit do ' if Day(rs("DatasDataInicio")) = intCount + 1 then ' dictDte(intCount, 1) = rs("DatasDescricao") ' rs.Movenext ' Else ' dictDte(intCount, 1) = " " ' End If ' dictDte(intCount, 2) = intCount + 1 ' intCount = intCount + 1 ' loop %> <!doctype html> <html> <head> <meta charset="utf-8"> <link href="/App/HOME/agenda/calendario/CSS/calendario.css" rel="stylesheet" type="text/css" /> </head> <body> <table id="tabCalendario"> <tr> <% '-- criar colunas com dias da semana For iDay = vbSunday To vbSaturday%> <th> <%=UCase(WeekDayName(iDay))%></th> <%Next %> </tr> <% '--cria linhas de semanas dtCurViewDay = DtPrevSunday(dtCurViewMonth) Response.Write "<tbody>" For iWeek = 0 To 5 Response.Write "<TR>" Dim sBGCOLOR sBGCOLOR = "#FFFFFF" Dim ariaHoje ariaHoje = "1" '-- cria as datas do calendário For iDay = 0 To 6 sBGCOLOR = "#FFFFFF" ariaHoje = "1" If Month(dtCurViewDay) = Month(dtCurViewMonth) Then ariaHoje = "1" 'Marca dia atual If dtCurViewDay = dtToday Then sBGCOLOR = "#C4E1FF" else sBGCOLOR = "#F5F5F5" ariaHoje = "" End If Response.Write "<TD bgcolor=" & sBGCOLOR & ">" '------------Caso seja o primeiro dia do mês, concatena o nome do mês abreviado Dim primeiroDia primeiroDia = "" If Day(dtCurViewDay) = 1 Then primeiroDia = " de " & MonthName(Month(dtCurViewDay),True)'true para mês abreviado End if Response.Write("<li value=" & Day(dtCurViewDay) &">"& Day(dtCurViewDay) & primeiroDia & "</li>") '------------ Exibe compromissos do banco de dados Dim meuDia, meuMes, meuAno meuDia = Day(rs("Inicio")) meuMes = Month(rs("Inicio")) meuAno = Year(rs("Inicio")) If meuDia = Day(dtCurViewDay) AND meuMes = Month(dtCurViewDay) AND meuAno = Year(dtCurViewDay) Then Response.Write "<span>" & rs("DatasDescricao") & "</span>" rs.Movenext End if dtCurViewDay = DateAdd("d", 1, dtCurViewDay) Response.Write "</TD>" Next Response.Write "</TR>" Next Response.Write "</tbody>" %> <%' --------END OF DRAW CALENDAR SECTION-------- conexao.Close set conexao = nothing %> </table> </body> </html>  

    • Por MarKteus
      Olá amigos
       
      Alguém sabe se é possível usar RecordSet.Sort no ASP clássico ?

      Estou tentando mas só to tomando Internal Server Error.

      Vejam

      Set RdsData = Info.ListarUsuarios
       
      Set nome = RdsData.Find "Usuario='Indra'" <= Linha que esta me fud,...
       
      mas já tentei
       
      nome = RdsData.Find "Usuario='Indra'"
       
      abaixo trecho da classe que gera o RecordSet
       
      Public Function ListarUsuarios()
      Set Rds = dao.AdoRecordset strSql = "SELECT * FROM USUARIO (NOLOCK)" With Rds .CursorLocation = 3 .CursorType = 2 .LockType = 3 Set ListarUsuarios = .Open(strSql, Connection) End With Connection.Close End Function  
       
       
×

Informação importante

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