Jeg har en forhandler oprettelses form, når man så sender formen sender man samtidig en mail til forhandleren.
Men her kommer problemet, alle tabeller er tomme, hvis man så submitter formen igen virker det ??
her er koden:
<% Response.Buffer = True %>
<html><head>
<title>indsæt usg data</title>
<BODY BGCOLOR="#FFFFFF"
</head><body>
<%
' Databaseforbindelse - husk at angive sti til din database
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; "
DSN = DSN & "DBQ=d:\websider\global\comgrosinfo.dk\comgrosinfo.dk\db\forhandler.mdb"
Conn.Open DSN
' SQL sætning opbygges
strSQL = "Insert into kunder (kundenr, forhandlernavn, forhandleradr, forhandlerpostnr, forhandlerby, forhandlertele, forhandleremail, forhandlerkontakt, forhandlerhoved, forhandlerstart, forhandleransat, forhandlervaerksted, forhandlerusg) values('" & Request.Form("kundenr") & "', '" & Request.Form("forhandlernavn") & "', '" & Request.Form("forhandleradr") & "', '" & Request.Form("forhandlerpostnr") & "', '" & Request.Form("forhandlerby") & "', '" & Request.Form("forhandlertele") & "', '" & Request.Form("forhandleremail") & "', '" & Request.Form("forhandlerkontakt") & "', '" & Request.Form("forhandlerhoved")& "', '" & Request.Form("forhandlerstart") & "', '" & Request.Form("forhandleransat") & "', '" & Request.Form("forhandlervaerksted") & "', '" & Request.Form("forhandlerusg") & "')"
' SQL sætning eksekveres
Conn.Execute(strSQL)
%>
<font face="Arial, Helvetica, sans-serif" size="1">Tak vi har nu modtaget Deres forhandler registrering.
<font face="Arial, Helvetica, sans-serif" size="1">En email er afsendt til Dem vedr. Deres oprettelses information.
<%
' Opbygger en dynamisk SQL streng
strSQL = "SELECT TOP 1 ID, kundenr, forhandlernavn, forhandleradr, forhandlerpostnr, forhandlerby, forhandlertele, forhandleremail, forhandlerkontakt, forhandlerhoved, forhandlerstart, forhandleransat, forhandlervaerksted, forhandlerusg FROM kunder WHERE"
strSQL = strSQL & " (kundenr LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (forhandlernavn LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (forhandleradr LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (forhandlerpostnr LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (forhandlerby LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (forhandlertele LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (forhandleremail LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (forhandlerhoved LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (forhandlerstart LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (forhandleransat LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (forhandlervaerksted LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (forhandlerusg LIKE '" & strKeyword & "')"
strSQL = strSQL & " ORDER BY ID DESC"
' Skaber DSNLess forbindelse til DBen
strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=d:\websider\global\comgrosinfo.dk\comgrosinfo.dk\db\forhandler.mdb"
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open strDSN
' Skaber et recordset udfra SQL strengen
Set rs = myConn.Execute(strSQL)
While Not rs.EOF
Response.Write rs("kundenr")
set jmail = server.createobject("JMAIL.SMTPMail")
jMail.sendername = "Forhandler oprettet"
jMail.sender = "postmaster@comgrosinfo.dk"
jMail.Subject = "Forhandler oprettet"
jMail.ServerAddress = "mail.comgrosinfo.dk"
jMail.AddRecipient "postmaster@comgrosinfo.dk"
Jmail.AddRecipientBCC "postmaster@comgrosinfo.dk"
jMail.Body = "Dette er et autosvar" & vbCrLf
jMail.Body = jMail.Body & "Her følger online informationer:" & vbCrLf & vbCrLf
jMail.Body = jMail.Body & "Forhandler info:" & vbCrLf
jMail.Body = jMail.Body & (rs("forhandlernavn")) & vbCrLf
jMail.Body = jMail.Body & (rs("forhandleradr")) & vbCrLf
jMail.Body = jMail.Body & (rs("forhandlerpostnr")) & (rs("forhandlerby")) & vbCrLf
jMail.Body = jMail.Body & (rs("forhandlertele")) & vbCrLf
jMail.Body = jMail.Body & (rs("forhandleremail")) & vbCrLf & vbCrLf
jMail.Body = jMail.Body & (rs("forhandlerkontakt")) & vbCrLf & vbCrLf
jMail.Body = jMail.Body & "Diverse info:" & vbCrLf
jMail.Body = jMail.Body & "Hovedaktivitet: " & (rs("forhandlerhoved")) & vbCrLf
jMail.Body = jMail.Body & "Etableret i: " & (rs("forhandlerstart")) & vbCrLf
jMail.Body = jMail.Body & "Antal ansatte: " & (rs("forhandleransat")) & vbCrLf
jMail.Body = jMail.Body & "Serviceværksted: " & (rs("forhandlervaerksted")) & vbCrLf
jMail.Body = jMail.Body & "Registreret: " & (rs("forhandlerusg")) & vbCrLf
jMail.Body = jMail.Body & "Kunde ID: " & (rs("kundenr")) & vbCrLf
jMail.Priority = 3
jMail.execute
rs.MoveNext()
Wend
If Not (rs.BOF Or rs.EOF) Then
' Hvis der er fundet poster på søgningen
Response.Write("Der var ikke nogen kunder!")
Else
End If
' Rydder op efter os
myConn.Close
Set myConn = Nothing
%>
</body>
</html>
Siden kan ses og prøves på:
www.comgrosinfo.dk/test.aspDenne del af koden er : test1.asp