Hallo,
Hiiiiiilfeeeeeee!!!
Ich versuche eine primitive eigene Chatseite zu erstellen.
Dafür habe ich eine riesige Datenbankabfrage gemacht. Ich weiss, man könnte es eleganter lösen (z.B. mit ElseIf), aber ich bin da noch nicht so erfahren, also habe ich einfach alles verschachtelt:
Dim strConnection
strConnection = "Driver={Microsoft Access Driver (\*.mdb)};DBQ=" & Server.MapPath("\fpdb\chat.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open strConnection
Set rs = Server.CreateObject("ADODB.Recordset")
Dim varText
varText = Request.Form("Kurznachricht")
If Not varText = "" Then
Response.Cookies("text\_working") = "request"
Dim varText1,varText2,varText3,varText4,varText5,varText6,varText7,varText8,varText9,varText10
strSQL1 = "SELECT Text FROM Chat WHERE Nr=1"
strSQL2 = "SELECT Text FROM Chat WHERE Nr=2"
strSQL3 = "SELECT Text FROM Chat WHERE Nr=3"
strSQL4 = "SELECT Text FROM Chat WHERE Nr=4"
strSQL5 = "SELECT Text FROM Chat WHERE Nr=5"
strSQL6 = "SELECT Text FROM Chat WHERE Nr=6"
strSQL7 = "SELECT Text FROM Chat WHERE Nr=7"
strSQL8 = "SELECT Text FROM Chat WHERE Nr=8"
strSQL9 = "SELECT Text FROM Chat WHERE Nr=9"
strSQL0 = "SELECT Text FROM Chat WHERE Nr=0"
Set rs = conn.Execute(strSQL1)
varText1 = rs("Text")
Set rs = conn.Execute(strSQL2)
varText2 = rs("Text")
Set rs = conn.Execute(strSQL3)
varText3 = rs("Text")
Set rs = conn.Execute(strSQL4)
varText4 = rs("Text")
Set rs = conn.Execute(strSQL5)
varText5 = rs("Text")
Set rs = conn.Execute(strSQL6)
varText6 = rs("Text")
Set rs = conn.Execute(strSQL7)
varText7 = rs("Text")
Set rs = conn.Execute(strSQL8)
varText8 = rs("Text")
Set rs = conn.Execute(strSQL9)
varText9 = rs("Text")
Set rs = conn.Execute(strSQL0)
varText10 = rs("Text")
conn.close
Set conn = Nothing
Set rs = Nothing
strConnection = "Driver={Microsoft Access Driver (\*.mdb)};DBQ=" & Server.MapPath("\fpdb\chat.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open strConnection
Set rs = Server.CreateObject("ADODB.Recordset")
Dim varTime1,varTime2,varTime3,varTime4,varTime5,varTime6,varTime7,varTime8,varTime9,varTime10
strSQL1 = "SELECT Time FROM Chat WHERE Nr=1"
strSQL2 = "SELECT Time FROM Chat WHERE Nr=2"
strSQL3 = "SELECT Time FROM Chat WHERE Nr=3"
strSQL4 = "SELECT Time FROM Chat WHERE Nr=4"
strSQL5 = "SELECT Time FROM Chat WHERE Nr=5"
strSQL6 = "SELECT Time FROM Chat WHERE Nr=6"
strSQL7 = "SELECT Time FROM Chat WHERE Nr=7"
strSQL8 = "SELECT Time FROM Chat WHERE Nr=8"
strSQL9 = "SELECT Time FROM Chat WHERE Nr=9"
strSQL10 = "SELECT Time FROM Chat WHERE Nr=0"
Set rs = conn.Execute(strSQL1)
varTime1 = rs("Time")
Set rs = conn.Execute(strSQL2)
varTime2 = rs("Time")
Set rs = conn.Execute(strSQL3)
varTime3 = rs("Time")
Set rs = conn.Execute(strSQL4)
varTime4 = rs("Time")
Set rs = conn.Execute(strSQL5)
varTime5 = rs("Time")
Set rs = conn.Execute(strSQL6)
varTime6 = rs("Time")
Set rs = conn.Execute(strSQL7)
varTime7 = rs("Time")
Set rs = conn.Execute(strSQL8)
varTime8 = rs("Time")
Set rs = conn.Execute(strSQL9)
varTime9 = rs("Time")
Set rs = conn.Execute(strSQL10)
varTime10 = rs("Time")
Dim varTime\_now
varTime\_now = Now()
If varText1 = "" Then
strSQL = "UPDATE Chat SET Text=" & varText & " WHERE Nr=1"
conn.Execute(strSQL)
conn.close
Set rs = Nothing
Set conn = Nothing
Response.Redirect("work\_with\_chatdata.asp?Eingabe=OK")
Else
If varText2 = "" Then
strSQL = "UPDATE Chat SET Text=" & varText & " WHERE Nr=2"
conn.Execute(strSQL)
conn.close
Set rs = Nothing
Set conn = Nothing
Response.Redirect("work\_with\_chatdata.asp?Eingabe=OK")
Else
If varText3 = "" Then
strSQL = "INSERT INTO Chat SET Text=" & varText & " WHERE Nr=3"
conn.Execute(strSQL)
conn.close
Set rs = Nothing
Set conn = Nothing
Response.Redirect("work\_with\_chatdata.asp?Eingabe=OK")
Else
If varText4 = "" Then
strSQL = "UPDATE Chat SET Text=" & varText & " WHERE Nr=4"
conn.Execute(strSQL)
conn.close
Set rs = Nothing
Set conn = Nothing
Response.Redirect("work\_with\_chatdata.asp?Eingabe=OK")
Else
If varText5 = "" Then
strSQL = "UPDATE Chat SET Text=" & varText & " WHERE Nr=5"
conn.Execute(strSQL)
conn.close
Set rs = Nothing
Set conn = Nothing
Response.Redirect("work\_with\_chatdata.asp?Eingabe=OK")
Else
If varText6 = "" Then
strSQL = "UPDATE Chat SET Text=" & varText & " WHERE Nr=6"
conn.Execute(strSQL)
conn.close
Set rs = Nothing
Set conn = Nothing
Response.Redirect("work\_with\_chatdata.asp?Eingabe=OK")
Else
If varText7 = "" Then
strSQL = "UPDATE Chat SET Text=" & varText & " WHERE Nr=7"
conn.Execute(strSQL)
conn.close
Set rs = Nothing
Set conn = Nothing
Response.Redirect("work\_with\_chatdata.asp?Eingabe=OK")
Else
If varText8 = "" Then
strSQL = "UPDATE Chat SET Text=" & varText & " WHERE Nr=8"
conn.Execute(strSQL)
conn.close
Set rs = Nothing
Set conn = Nothing
Response.Redirect("work\_with\_chatdata.asp?Eingabe=OK")
Else
If varText9 = "" Then
strSQL = "UPDATE Chat SET Text=" & varText & " WHERE Nr=9"
conn.Execute(strSQL)
conn.close
Set rs = Nothing
Set conn = Nothing
Response.Redirect("work\_with\_chatdata.asp?Eingabe=OK")
Else
If varText10 = "" Then
strSQL = "UPDATE Chat SET Text=" & varText & " WHERE Nr=10"
conn.Execute(strSQL)
conn.close
Set rs = Nothing
Set conn = Nothing
Response.Redirect("work\_with\_chatdata.asp?Eingabe=OK")
Else
If varTime1
Eigentlich müsste mindestens eins der Ifs zutreffen. Wenn ich aber im Web die Seite aufrufe, scheit keines zuzutreffen. Ist vielleicht irgendetwas mit der Verschachtelung der Ifs falsch?
Ich bin dankbar für jeden Hinweis!
mfg
Jannik