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??? :( :( :(
 
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