webForumDet fria alternativet

sätta variabel till null

ASP

1 svar · 231 visningar · startad av mattiasnordin

Medlem sedan maj 20012 080 inlägg
Frågan#1

Hej.

Jag har ett fält i en access 2003 databas som ska vara antingen null eller en siffra.

Nu undrar jag hur jag ändrar tillbaka till null efter att jag har satt en siffra.

Hur ser syntaxen ut? Måste det stå null i sql frågan eller går det att

id sSetThisIdToMaster = "" then 
sSetThisIdToMaster = null 
end if
sql_question = "INSERT INTO T_temp (sidan_html, huvud_meny_id, sub_meny_till_sida_id, fil_katalog_path, default_sida, lank_namn, visa_publikt, orginal_sida_id, site_id, sidan_uppdaterad_datum) "
	sql_question = sql_question &" VALUES "
	sql_question = sql_question &"('" &sHtmlSidan &"',"
	sql_question = sql_question &"" &sHuvudMenyId &","
'	sql_question = sql_question &""	&null&","
	sql_question = sql_question &""	&sSetThisIdToMaster &","
	sql_question = sql_question &"'',"
	sql_question = sql_question &"'" &sDefaultSida &"',"
	sql_question = sql_question &"'" &sLankNamn &"',"
	sql_question = sql_question &"" &sVisaPublikt &","
	sql_question = sql_question &"" &sValdSidaId &","
	sql_question = sql_question &"" &sSiteId &","
	sql_question = sql_question &"'" &now &"')"
	response.write "<hr><b>DEBUG Insert ny text i skarpa databasen:</b> " &sql_question &"<hr>"
	connect.execute(sql_question)
Medlem sedan juni 200032 967 inlägg
#2

Det måste stå null i SQL-frågan, vilket innebär att du måste använda strängen null.

id sSetThisIdToMaster = "" then 
sSetThisIdToMaster = "null" 
end if
250 ms totalt · 4 externa anrop · v20260731065814-full.1dc6f849
128 ms — deklarationer (db)
0 ms — hämta statistik (cache)
120 ms — hämta tråd, inlägg och bilagor (db)
125 ms — ändringar (db)