Problemi con INSERT

grottafelix

Utente Attivo
5 Mar 2003
2.410
2
38
45
Parco chiuso -
www.girsms.com
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)
	[COLOR=red]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[/COLOR] 
	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
		[COLOR=red]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"[/COLOR] 	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??? :( :( :(
 

lukeonweb

Utente Attivo
5 Mar 2003
5.175
13
38
46
Napoli
www.lucaruggiero.it
Quando aggiorni una data, se il campo è di tipo data, devi usare #

campo_data = #' & Date() & '#

Prova, non ricordo se i # vanno dentro o fuori agli apici.

Leggi bene il messaggio Felix...

> Data type mismatch in criteria expression
 
Discussioni simili
Autore Titolo Forum Risposte Data
Z problemi con foreach insert into PHP 10
E Problemi auto increment con query Insert Into Select MySQL 2
M Problemi con la insert PHP 1
T problemi con dati menu a tendina HTML e CSS 2
M Upload immagine con javascript problemi con FormData() Javascript 1
A Problemi con move_uploaded_file PHP 7
M Problemi con la stampa dei valori in php PHP 1
L Problemi con il login PHP 2
R Tutto su utf-8 ma ancora problemi con i caratteri speciali in mysql MySQL 1
B javascript per problemi con pdf e Safari Javascript 0
M Problemi con creazione maschere Presentati al Forum 1
M Problemi con query a più tabelle PHP 3
S Problemi delle funzioni eliminate con PHP e MySQL PHP 4
M Problemi con blog Grav CMS (Content Management System) 0
S incoerenza di stampa. problemi con il magenta Photoshop 3
A problemi con paypall Java 1
S Problemi con modulo upload video php (help!) PHP 0
felino [Windows 8.1] Problemi con connessione WiFi Windows e Software 0
E [PHP] problemi nuova riga con fwrite su piattaforma android PHP 5
O [HTML] problemi con la regola "background-attachment: fixed" in EDGE HTML e CSS 0
M [PHP] Problemi con query unione PHP 11
M [PHP] Problemi con select PHP 6
ANDREA20 [HTML] problemi con il footer HTML e CSS 1
D [MS Access] problemi con inserimento campo in una maschera MS Access 6
M [PHP] Problemi con il riconoscimento login. PHP 21
A [WordPress] problemi con xampp WordPress 2
M Problemi con database Apache/2.4.37 (Win32) OpenSSL/1.1.1a PHP/7.3.1 PHP 6
S [PHP] problemi con le sessioni PHP 3
T [PHP] problemi con il browser PHP 0
Andrea_Ventura [HTML] Problemi con effetto hover HTML e CSS 5
M [PHP] Problemi con login facebook PHP 0
Andrea_Ventura [HTML] Problemi con visualizzazione Navigation Bar HTML e CSS 10
andreas88 Creare file .htaccess per risolvere alcuni problemi con il tester SEO SEO e Posizionamento 0
Eugene [Joomla] Problemi con modulo per strutture alberghiere JHotelreservation starter Joomla 6
F [PHP] Problemi di base con bot di telegram PHP 9
M [Photoshop] Problemi con importazione immagini trasparenti in indesign Photoshop 0
E [Photoshop] Problemi con dimensioni immagini Photoshop 12
G [HTML] Problemi con inserimento immagini HTML e CSS 7
L Problemi con Javascript e Mustache Javascript 0
G Invio Mail con PHPMailer, problemi SMTP PHP 7
A [Javascript] problemi con javascrip e posizione GPS html5 Javascript 6
D Due problemi con Photoshop... Photoshop 1
G Problemi con pagina online.php di una chat in php PHP 38
S Problemi con impostazioni php PHP 3
P Problemi con AndroidStudio Sviluppo app per Android 0
S Problemi con Dell Precision T5400 Windows e Software 2
F ciao, sono ferro e ho bisogno di aiuto per problemi con la mail di alice.it Presentati al Forum 1
S [PHP] Problemi con Login e pagina Utente PHP 5
Z problemi con swf e chrome o sistemi portatili Webdesign e Grafica 5
N Problemi connettività con Tp Link EAP 110 Reti LAN e Wireless 0

Discussioni simili