Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11
  1. #1
    Utente di HTML.it L'avatar di ubbicom
    Registrato dal
    Mar 2004
    Messaggi
    1,407

    [ASP+XML] Errori persistenti su lettura testo

    Buona Pasqua a tutti.

    Ho due problemi con del codice ASP che utilizza l'oggetto MSXML2.DOMDocument.4.0 per leggere dei Feed ed inserirli in un database mysql.

    Gli errori sono i seguenti:

    Tipo di errore:
    Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    [MySQL][ODBC 5.1 Driver][mysqld-5.1.45-community]Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='
    e


    Tipo di errore:
    Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    [MySQL][ODBC 5.1 Driver][mysqld-5.1.45-community]Incorrect string value: '\xC2\x93un p...' for column 'quote' at row 1
    Per il primo non so che cosa sia, per il secondo invece si verifica quando nel testo del feed si presentano delle virgolette: "un paese... "

    Come posso risolvere?
    Grazie-

  2. #2

  3. #3
    Utente di HTML.it L'avatar di ubbicom
    Registrato dal
    Mar 2004
    Messaggi
    1,407
    Originariamente inviato da optime
    posta anche il codice
    Ok:

    codice:
    <%
    
    Response.Expires = -1
    
    Randomize()
    intUP  = 199
    intLow = 1
    
    DisplayFeed("http://www.paginaweb/rss/edo.xml")
    
    Sub DisplayFeed(sURL)    
    dim objXML	
    Set objXML = CreateObject("MSXML2.DOMDocument.4.0")	
    objXML.async = False	
    objXML.validateOnParse = false	
    objXML.resolveExternals = false	
    objXML.preserveWhiteSpace = false	
    objXML.setProperty "ServerHTTPRequest", True
    if (objXML.Load(sURL)) then
    Dim i, k, objChannel, objItemList,sChildNodeName,sChildNodeText,iTotalItems,iCount,objItem,j,sLinkTxt,sLinkURL 
    		
    Set objItemList = objXML.getElementsByTagName("channel")		
    iTotalItems = objItemList.length - 1 		
    If (iTotalItems < 0) Then			
    dim RootNamespace: RootNamespace = objXML.documentElement.namespaceURI 			
    objXML.setProperty "SelectionNamespaces","xmlns:at='" & RootNamespace & "'"	 		
    Set objItemList = objXML.selectNodes("//at:feed")			
    iTotalItems = objItemList.length - 1		
    End If 	    
    
    i = 0		
    For iCount = 0 to iTotalItems			
    Set objItem = objItemList.item(iCount)			
    For j = 0 to objItem.childNodes.length - 1	
    			
    sChildNodeName = objItem.childNodes(j).nodeName				
    sChildNodeText = objItem.childNodes(j).text 
               
    If (sChildNodeName = "title") Then					
    sLinkTxt = sChildNodeText			   
    ElseIf (sChildNodeName = "link") Then					
    sLinkURL = sChildNodeText
    ElseIf (sChildNodeName = "Description") Then 
    sDesc = sChildNodeText
    ElseIf (sChildNodeName = "pubDate") Then 
    sDate = sChildNodeText	
    
    myDate = split (sDate , " " )
    if Lcase(left(trim(MyDate(2)),3)) = "jan" then Mnth = "01"
    if Lcase(left(trim(MyDate(2)),3)) = "feb" then Mnth = "02"
    if Lcase(left(trim(MyDate(2)),3)) = "mar" then Mnth = "03"
    if Lcase(left(trim(MyDate(2)),3)) = "apr" then Mnth = "04"
    if Lcase(left(trim(MyDate(2)),3)) = "may" then Mnth = "05"
    if Lcase(left(trim(MyDate(2)),3)) = "jun" then Mnth = "06"
    if Lcase(left(trim(MyDate(2)),3)) = "jul" then Mnth = "07"
    if Lcase(left(trim(MyDate(2)),3)) = "aug" then Mnth = "08"
    if Lcase(left(trim(MyDate(2)),3)) = "sep" then Mnth = "09"
    if Lcase(left(trim(MyDate(2)),3)) = "oct" then Mnth = "10"
    if Lcase(left(trim(MyDate(2)),3)) = "nov" then Mnth = "11"
    if Lcase(left(trim(MyDate(2)),3)) = "dec" then Mnth = "12"
    DataFinale = MyDate(3) & "-" & Mnth & "-" & MyDate(1)
    End If			
    Next			
    response.write "" & sLinkTxt & "" & vbCrLf
    Next	
    
    Set objItemList = nothing		
    Set objItem = nothing         
    Set objItemList = objXML.getElementsByTagName("item")		
    iTotalItems = objItemList.length - 1         
    
    If (iTotalItems < 0) Then			
    Set objItemList = objXML.getElementsByTagName("entry")			
    iTotalItems = objItemList.length - 1		
    end if         
    
    If (iTotalItems < 0) Then			
    RootNamespace = objXML.documentElement.namespaceURI 			
    objXML.setProperty "SelectionNamespaces","xmlns:at='" & RootNamespace & "'"	 		
    Set objItemList = objXML.selectNodes("//at:feed")			
    iTotalItems = objItemList.length - 1		
    End If 	    
    
    i = 0		
    For iCount = 0 to iTotalItems			
    Set objItem = objItemList.item(iCount)			
    For j = 0 to objItem.childNodes.length - 1				
    sChildNodeName = objItem.childNodes(j).nodeName				
    sChildNodeText = objItem.childNodes(j).text 	           
    
    If (sChildNodeName = "title") Then					
    sLinkTxt = sChildNodeText			   
    ElseIf (sChildNodeName = "link") Then					
    sLinkURL = sChildNodeText	
    ElseIf (sChildNodeName = "description") Then 
    sDesc = sChildNodeText
    ElseIf (sChildNodeName = "pubDate") Then 
    sDate = sChildNodeText		
    
    myDate = split (sDate, " " )
    if Lcase(left(trim(MyDate(2)),3)) = "jan" then Mnth = "01"
    if Lcase(left(trim(MyDate(2)),3)) = "feb" then Mnth = "02"
    if Lcase(left(trim(MyDate(2)),3)) = "mar" then Mnth = "03"
    if Lcase(left(trim(MyDate(2)),3)) = "apr" then Mnth = "04"
    if Lcase(left(trim(MyDate(2)),3)) = "may" then Mnth = "05"
    if Lcase(left(trim(MyDate(2)),3)) = "jun" then Mnth = "06"
    if Lcase(left(trim(MyDate(2)),3)) = "jul" then Mnth = "07"
    if Lcase(left(trim(MyDate(2)),3)) = "aug" then Mnth = "08"
    if Lcase(left(trim(MyDate(2)),3)) = "sep" then Mnth = "09"
    if Lcase(left(trim(MyDate(2)),3)) = "oct" then Mnth = "10"
    if Lcase(left(trim(MyDate(2)),3)) = "nov" then Mnth = "11"
    if Lcase(left(trim(MyDate(2)),3)) = "dec" then Mnth = "12"
    
    DataFinale = MyDate(3) & "-" & Mnth & "-" & MyDate(1)
    	
    End If	
    		
    Next 			
    response.write sDesc & " --- " & sDate & " ---"& replace(sLinkTxt,"&","&amp;") & "
    " & vbCrLf	
    
    intRange = intUp - intLow 
    intRandom = CInt ((intRange * Rnd()) + intLow)
    intRange2 = intUp + intLow 
    intRandom2 = CInt ((intRange * Rnd()) - intLow)
    
    strSQL = "INSERT INTO TBL"
    ...
    objconn.execute strSQL
    response.write strSQL & "
    
    "
    response.flush()	
    
    i = i + 1	
    
    Next 	
    
    else		
    response.write("Error code:" & objXML.parseError.errorCode & "
    ")		
    response.write("Error reason:" & objXML.parseError.reason & "
    
    ")	
    end If 	
    set objItemList = nothing    
    set objXML = nothing
    
    end sub		
    
    %>

  4. #4
    e quale parte del codice ti dà problemi?

  5. #5
    Utente di HTML.it L'avatar di ubbicom
    Registrato dal
    Mar 2004
    Messaggi
    1,407
    Originariamente inviato da optime
    e quale parte del codice ti dà problemi?
    Quest'errore:

    [MySQL][ODBC 5.1 Driver][mysqld-5.1.45-community]Incorrect string value: '\xC2\x93un p...' for column 'quote' at row 1
    Nella query di inserimento:

    codice:
    strSQL = "INSERT INTO TBL_Q "
    strSQL = strSQL & " (quote)"
    strSQL = strSQL & "  VALUES"
    strSQL = strSQL & " ('" & pulisci(sDesc) & "')"
    objconn.execute strSQL

    Quest'altro errore:

    Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    [MySQL][ODBC 5.1 Driver][mysqld-5.1.45-community]Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='
    quando inserisco una query select per un controllo di duplicti prima della query insert:

    codice:
    query_select = "SELECT * FROM TBL_Q "
    query_select = query_select & " WHERE "
    query_select = query_select & " quote  = '" & pulisci(sDesc) & "' "

  6. #6
    per il problema della INSERT usa la solita replace di un apice singolo con due apici singoli

  7. #7
    Utente di HTML.it L'avatar di ubbicom
    Registrato dal
    Mar 2004
    Messaggi
    1,407
    codice:
    strSQL = "INSERT INTO TBL_Q "
    strSQL = strSQL & " (quote)"
    strSQL = strSQL & "  VALUES"
    strSQL = strSQL & " ('" & replace(sDesc, "'", "''") & "')"
    objconn.execute strSQL
    Microsoft OLE DB Provider for ODBC Drivers error '80004005'
    [MySQL][ODBC 5.1 Driver][mysqld-5.1.45-community]Incorrect string value: '\xC2\x93un p...' for column 'quote' at row 1

  8. #8
    ----------------------------------------------------
    impariamo a fare un po' di debug

    *subito* dopo la composizione della stringa SQL metti

    Response.Write "maGGica SQL...: " & strSQL
    Response.Flush

    poi posta quello che viene a video
    ----------------------------------------------------


    poi, che tipo di colonna è "quote"? ("quote"? non è una parola riservata?)

  9. #9
    Utente di HTML.it L'avatar di ubbicom
    Registrato dal
    Mar 2004
    Messaggi
    1,407
    Originariamente inviato da optime
    ----------------------------------------------------
    impariamo a fare un po' di debug

    *subito* dopo la composizione della stringa SQL metti

    Response.Write "maGGica SQL...: " & strSQL
    Response.Flush

    poi posta quello che viene a video
    ----------------------------------------------------


    poi, che tipo di colonna è "quote"? ("quote"? non è una parola riservata?)
    Non mi sembra che «quote» sia una parola riservata di mysql: http://dev.mysql.com/doc/refman/5.1/...ved-words.html

    Il risultato della query è il seguente:
    codice:
    INSERT INTO TBL_Q 
    ( quote) 
    VALUES
    ( '?un paese da visitare?' )

  10. #10
    cosa stanno a significare quei due punti interrogativi?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.