Visualizzazione dei risultati da 1 a 6 su 6

Discussione: Problemi con INSERT

  1. #1

    Problemi con INSERT

    codice:
    <%
    If Request.querystring("mode") = "updatedb" then 
    	strUserName = Session("userName")
    	strHeading = Request.Form("txtHeading")
    	strContent = Request.Form("txtContent")
    	strID = Clng(Request.Form("txtID"))
    	tipoNews = Request.Form("tipoNews")
    	strHeading = fieldReplace(strHeading)
    	strContent = fieldReplace(strContent)
    	strSQL = "UPDATE tblnews SET tblnews.heading='" & strHeading & "',tblnews.content='" & strContent & "',tblnews.postedby='" & strUserName & "',tblnews.Timestamp='" & date() & "'," & "tblnews.tipo =" & tipoNews & " WHERE ID =" & strID
    	adoCon.Execute(strSQL)
    	Set adoCon = Nothing
    	Response.Redirect"news.asp?mode=listnews"
    End If
    %>
    <%
    If Request.querystring("mode") = "view" then 
    	userAdmin = Session("userAdmin")
    	Set rsSettings = Server.CreateObject("ADODB.Recordset")
    	strSettingsSQL = "SELECT shownum,contentbgcolor,infobgcolor,infotextcolor,bordercolor,headbgcolor FROM tblsettings"
    	rsSettings.Open strSettingsSQL, adoCon
    	Set rsViewNews = Server.CreateObject("ADODB.Recordset")
    	if session("UserAdmin") = 2 or session("UserAdmin") = 3 then
    		strViewSQL = "SELECT TOP " & rsSettings("shownum") & " heading, [ID], [Timestamp], postedby, IdUser, img, content, attiva, giorni FROM tblnews WHERE IdUser = " & Session("userID") & " AND attiva = true ORDER BY [ID] DESC"
    	elseif session("UserAdmin") = 1 then
    		strViewSQL = "SELECT TOP " & rsSettings("shownum") & " heading, [ID], [Timestamp], postedby, img, content, attiva, giorni FROM tblnews ORDER BY [ID] DESC"
    	end if
    	rsViewNews.Open strViewSQL, adoCon
    
    dim newsSI
    newsSi=0
    Do While NOT rsViewNews.EOF
    newsSi = newsSi+1
    %>
    Quando vado per modificare un record fa finta di modificarmi i campi fine e inizio (dove c'è una data)

    allora ho fatto delle modifiche allo script in questo modo:


    <%
    codice:
    If Request.querystring("mode") = "updatedb" then 
    	strUserName = Session("userName")
    	strHeading = Request.Form("txtHeading")
    	strContent = Request.Form("txtContent")
    	strID = Clng(Request.Form("txtID"))
    	tipoNews = Request.Form("tipoNews")
    	strHeading = fieldReplace(strHeading)
    	strContent = fieldReplace(strContent)
    	strSQL = "UPDATE tblnews SET tblnews.heading='" & strHeading & "',tblnews.content='" & strContent & "',tblnews.Inizio='" & strInizio & "',tblnews.Fine='" & strFine & "',tblnews.postedby='" & strUserName & "',tblnews.Timestamp='" & date() & "'," & "tblnews.tipo =" & tipoNews & " WHERE ID =" & strID 
    	adoCon.Execute(strSQL)
    	Set adoCon = Nothing
    	Response.Redirect"news.asp?mode=listnews"
    End If
    %>
    <%
    If Request.querystring("mode") = "view" then 
    	userAdmin = Session("userAdmin")
    	Set rsSettings = Server.CreateObject("ADODB.Recordset")
    	strSettingsSQL = "SELECT shownum,contentbgcolor,infobgcolor,infotextcolor,bordercolor,headbgcolor FROM tblsettings"
    	rsSettings.Open strSettingsSQL, adoCon
    	Set rsViewNews = Server.CreateObject("ADODB.Recordset")
    	if session("UserAdmin") = 2 or session("UserAdmin") = 3 then
    		strViewSQL = "SELECT TOP " & rsSettings("shownum") & " heading, [ID], [Timestamp], postedby, IdUser, img, inizio, fine, content, attiva, giorni FROM tblnews WHERE IdUser = " & Session("userID") & " AND attiva = true ORDER BY [ID] DESC"
    	elseif session("UserAdmin") = 1 then
    		strViewSQL = "SELECT TOP " & rsSettings("shownum") & " heading, [ID], [Timestamp], postedby, img, content, inizio, fine, attiva, giorni FROM tblnews ORDER BY [ID] DESC" 	end if
    	rsViewNews.Open strViewSQL, adoCon
    
    dim newsSI
    newsSi=0
    Do While NOT rsViewNews.EOF
    newsSi = newsSi+1
    %>
    Ma il browser mi da errore:

    Microsoft JET Database Engine error '80040e07'

    Data type mismatch in criteria expression.

    modifica_news.asp, line 521

    la riga 521 è: adoCon.Execute(strSQL)
    la riga 520 è: strSQL = "UPDATE tblnews SET tblnews.heading='" & strHeading & "',tblnews.content='" & strContent & "',tblnews.Inizio='" & strInizio & "',tblnews.Fine='" & strFine & "',tblnews.postedby='" & strUserName & "',tblnews.Timestamp='" & date() & "'," & "tblnews.tipo =" & tipoNews & " WHERE ID =" & strID


    Che succede???

  2. #2
    Ci sono dati numerici vuoti.
    Fatti stampare la query sql senza eseguirla.

  3. #3
    Originariamente inviato da Mems
    Ci sono dati numerici vuoti.
    Fatti stampare la query sql senza eseguirla.
    quindi?

  4. #4
    Inserisci questo subito dopo la query

    codice:
    response.write strSQL
    response.end
    e vedi cosa ti stampa a video.

  5. #5
    Originariamente inviato da Dirk Pitt
    Inserisci questo subito dopo la query

    codice:
    response.write strSQL
    response.end
    e vedi cosa ti stampa a video.
    niente...non fa nulla...non effettua nessuna modifica. ma non da neanche errore.

  6. #6
    Cosa ti stampa a video.
    Quel codice serve per stamparti a video la tua query.

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.