Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Into

Status
Not open for further replies.

softboy12

ISP
Feb 19, 2004
66
0
0
CH
Hi all

I use the following code below to insert Datas in a sql Database received from a asp Page
------------------------------------------------------------

' Open Connection to the database
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str
Select Case a
Case "C": ' Get a record to display
tkey = "" & key & ""
strsql = "SELECT * FROM [Kunden] WHERE [ID]=" & tkey
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn
If rs.Eof Then
Response.Clear
Response.Redirect "Kundenlist.asp"
Else
rs.MoveFirst

' Get the field contents
x_ID = rs("ID")
x_Domain = rs("Domain")
x_TLD = rs("TLD")
x_LoginName = rs("LoginName")
x_Passwort = rs("Passwort")
x_Service = rs("Service")
x_Kundennummer = rs("Kundennummer")
x_FK_ID_Server = rs("FK_ID_Server")
x_Erfasst_am = rs("Erfasst_am")
x_gesperrt = rs("gesperrt")
x_Bemerkungen = rs("Bemerkungen")
x_alte_infos = rs("alte_infos")
x_alg_infos = rs("alg_infos")
x_best_anm = rs("best_anm")
x_Reseller = rs("Reseller")
x_Reseller_nummer = rs("Reseller_nummer")
x_Anrede_best = rs("Anrede_best")
x_Firma_best = rs("Firma_best")
x_Nname_best = rs("Nname_best")
x_Vorname_best = rs("Vorname_best")
x_Strasse_best = rs("Strasse_best")
x_Postfach_best = rs("Postfach_best")
x_PLZ_best = rs("PLZ_best")
x_Ort_best = rs("Ort_best")
x_Telefon_best = rs("Telefon_best")
x_Fax_best = rs("Fax_best")
x_Land_best = rs("Land_best")
x_Email_best = rs("Email_best")
x_Anrede_re = rs("Anrede_re")
x_Firma_re = rs("Firma_re")
x_Nname_re = rs("Nname_re")
x_Vorname_re = rs("Vorname_re")
x_Strasse_re = rs("Strasse_re")
x_Postfach_re = rs("Postfach_re")
x_PLZ_re = rs("PLZ_re")
x_Ort_re = rs("Ort_re")
x_Telefon_re = rs("Telefon_re")
x_Fax_re = rs("Fax_re")
x_Land_re = rs("Land_re")
x_Email_re = rs("Email_re")
x_Anrede_tec = rs("Anrede_tec")
x_Firma_tec = rs("Firma_tec")
x_Nname_tec = rs("Nname_tec")
x_Vorname_tec = rs("Vorname_tec")
x_Strasse_tec = rs("Strasse_tec")
x_Postfach_tec = rs("Postfach_tec")
x_PLZ_tec = rs("PLZ_tec")
x_Ort_tec = rs("Ort_tec")
x_Telefon_tec = rs("Telefon_tec")
x_Fax_tec = rs("Fax_tec")
x_Land_tec = rs("Land_tec")
x_Email_tec = rs("Email_tec")
x_Kontrolliert = rs("Kontrolliert")
x_erfasst_durch = rs("erfasst_durch")
x_MXrecord = rs("MXrecord")
x_Survey = rs("Survey")
x_sperrdatum = rs("sperrdatum")
x_Domainreg = rs("Domainreg")
End If
rs.Close
Set rs = Nothing
Case "A": ' Add

' Get fields from form
x_ID = Request.Form("x_ID")
x_Domain = Request.Form("x_Domain")
x_TLD = Request.Form("x_TLD")
x_LoginName = Request.Form("x_LoginName")
x_Passwort = Request.Form("x_Passwort")
x_Service = Request.Form("x_Service")
x_Kundennummer = Request.Form("x_Kundennummer")
x_FK_ID_Server = Request.Form("x_FK_ID_Server")
x_Erfasst_am = Request.Form("x_Erfasst_am")
x_gesperrt = Request.Form("x_gesperrt")
x_Bemerkungen = Request.Form("x_Bemerkungen")
x_alte_infos = Request.Form("x_alte_infos")
x_alg_infos = Request.Form("x_alg_infos")
x_best_anm = Request.Form("x_best_anm")
x_Reseller = Request.Form("x_Reseller")
x_Reseller_nummer = Request.Form("x_Reseller_nummer")
x_Anrede_best = Request.Form("x_Anrede_best")
x_Firma_best = Request.Form("x_Firma_best")
x_Nname_best = Request.Form("x_Nname_best")
x_Vorname_best = Request.Form("x_Vorname_best")
x_Strasse_best = Request.Form("x_Strasse_best")
x_Postfach_best = Request.Form("x_Postfach_best")
x_PLZ_best = Request.Form("x_PLZ_best")
x_Ort_best = Request.Form("x_Ort_best")
x_Telefon_best = Request.Form("x_Telefon_best")
x_Fax_best = Request.Form("x_Fax_best")
x_Land_best = Request.Form("x_Land_best")
x_Email_best = Request.Form("x_Email_best")
x_Anrede_re = Request.Form("x_Anrede_re")
x_Firma_re = Request.Form("x_Firma_re")
x_Nname_re = Request.Form("x_Nname_re")
x_Vorname_re = Request.Form("x_Vorname_re")
x_Strasse_re = Request.Form("x_Strasse_re")
x_Postfach_re = Request.Form("x_Postfach_re")
x_PLZ_re = Request.Form("x_PLZ_re")
x_Ort_re = Request.Form("x_Ort_re")
x_Telefon_re = Request.Form("x_Telefon_re")
x_Fax_re = Request.Form("x_Fax_re")
x_Land_re = Request.Form("x_Land_re")
x_Email_re = Request.Form("x_Email_re")
x_Anrede_tec = Request.Form("x_Anrede_tec")
x_Firma_tec = Request.Form("x_Firma_tec")
x_Nname_tec = Request.Form("x_Nname_tec")
x_Vorname_tec = Request.Form("x_Vorname_tec")
x_Strasse_tec = Request.Form("x_Strasse_tec")
x_Postfach_tec = Request.Form("x_Postfach_tec")
x_PLZ_tec = Request.Form("x_PLZ_tec")
x_Ort_tec = Request.Form("x_Ort_tec")
x_Telefon_tec = Request.Form("x_Telefon_tec")
x_Fax_tec = Request.Form("x_Fax_tec")
x_Land_tec = Request.Form("x_Land_tec")
x_Email_tec = Request.Form("x_Email_tec")
x_Kontrolliert = Request.Form("x_Kontrolliert")
x_erfasst_durch = Request.Form("x_erfasst_durch")
x_MXrecord = Request.Form("x_MXrecord")
x_Survey = Request.Form("x_Survey")
x_sperrdatum = Request.Form("x_sperrdatum")
x_Domainreg = Request.Form("x_Domainreg")
x_InhRe = Request.Form("x_InhRe")

' Open record
strsql = "SELECT * FROM [Kunden] WHERE 0 = 1"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 1, 2
rs.AddNew
tmpFld = x_ID
If Not IsNumeric(tmpFld) Then tmpFld = 0
srchFld = tmpFld
strsql = "SELECT * FROM [Kunden] WHERE [ID] = " & srchFld
Set rschk = conn.Execute(strsql)
If Not rschk.Eof Then
Response.Write "Achtung doppelte Laufnummer -- ID, value = " & tmpFld & "<br>"
Response.Write "Im Browser auf zurückklicken und nochmals versuchen!"
Response.End
End If
rschk.Close
Set rschk = Nothing
rs("ID") = CLng(tmpFld)
tmpFld = Trim(x_Domain)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Domain") = tmpFld
tmpFld = Trim(x_TLD)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("TLD") = tmpFld
tmpFld = Trim(x_LoginName)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("LoginName") = tmpFld
tmpFld = Trim(x_Passwort)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Passwort") = tmpFld
tmpFld = Trim(x_Service)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Service") = tmpFld
tmpFld = Trim(x_Kundennummer)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Kundennummer") = tmpFld
tmpFld = Trim(x_FK_ID_Server)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("FK_ID_Server") = tmpFld
tmpFld = x_Erfasst_am
If Not IsNumeric(tmpFld) Then tmpFld = 0
rs("Erfasst_am") = CLng(tmpFld)
tmpFld = x_gesperrt
If tmpFld = "1" Then
rs("gesperrt") = True
Else
rs("gesperrt") = False
End If
tmpFld = Trim(x_Bemerkungen)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Bemerkungen") = tmpFld
tmpFld = Trim(x_alte_infos)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("alte_infos") = tmpFld
tmpFld = Trim(x_alg_infos)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("alg_infos") = tmpFld
tmpFld = Trim(x_best_anm)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("best_anm") = tmpFld
tmpFld = x_Reseller
If tmpFld = "1" Then
rs("Reseller") = True
Else
rs("Reseller") = False
End If
tmpFld = Trim(x_Reseller_nummer)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Reseller_nummer") = tmpFld
tmpFld = Trim(x_Anrede_best)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Anrede_best") = tmpFld
tmpFld = Trim(x_Firma_best)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Firma_best") = tmpFld
tmpFld = Trim(x_Nname_best)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Nname_best") = tmpFld
tmpFld = Trim(x_Vorname_best)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Vorname_best") = tmpFld
tmpFld = Trim(x_Strasse_best)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Strasse_best") = tmpFld
tmpFld = Trim(x_Postfach_best)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Postfach_best") = tmpFld
tmpFld = Trim(x_PLZ_best)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("PLZ_best") = tmpFld
tmpFld = Trim(x_Ort_best)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Ort_best") = tmpFld
tmpFld = Trim(x_Telefon_best)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Telefon_best") = tmpFld
tmpFld = Trim(x_Fax_best)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Fax_best") = tmpFld
tmpFld = Trim(x_Land_best)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Land_best") = tmpFld
tmpFld = Trim(x_Email_best)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Email_best") = tmpFld
tmpFld = Trim(x_Anrede_re)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Anrede_re") = tmpFld
tmpFld = Trim(x_Firma_re)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Firma_re") = tmpFld
tmpFld = Trim(x_Nname_re)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Nname_re") = tmpFld
tmpFld = Trim(x_Vorname_re)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Vorname_re") = tmpFld
tmpFld = Trim(x_Strasse_re)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Strasse_re") = tmpFld
tmpFld = Trim(x_Postfach_re)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Postfach_re") = tmpFld
tmpFld = Trim(x_PLZ_re)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("PLZ_re") = tmpFld
tmpFld = Trim(x_Ort_re)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Ort_re") = tmpFld
tmpFld = Trim(x_Telefon_re)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Telefon_re") = tmpFld
tmpFld = Trim(x_Fax_re)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Fax_re") = tmpFld
tmpFld = Trim(x_Land_re)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Land_re") = tmpFld
tmpFld = Trim(x_Email_re)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Email_re") = tmpFld
tmpFld = Trim(x_Anrede_tec)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Anrede_tec") = tmpFld
tmpFld = Trim(x_Firma_tec)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Firma_tec") = tmpFld
tmpFld = Trim(x_Nname_tec)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Nname_tec") = tmpFld
tmpFld = Trim(x_Vorname_tec)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Vorname_tec") = tmpFld
tmpFld = Trim(x_Strasse_tec)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Strasse_tec") = tmpFld
tmpFld = Trim(x_Postfach_tec)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Postfach_tec") = tmpFld
tmpFld = Trim(x_PLZ_tec)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("PLZ_tec") = tmpFld
tmpFld = Trim(x_Ort_tec)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Ort_tec") = tmpFld
tmpFld = Trim(x_Telefon_tec)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Telefon_tec") = tmpFld
tmpFld = Trim(x_Fax_tec)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Fax_tec") = tmpFld
tmpFld = Trim(x_Land_tec)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Land_tec") = tmpFld
tmpFld = Trim(x_Email_tec)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Email_tec") = tmpFld
tmpFld = x_Kontrolliert
If tmpFld = "1" Then
rs("Kontrolliert") = True
Else
rs("Kontrolliert") = False
End If
tmpFld = Trim(x_erfasst_durch)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("erfasst_durch") = tmpFld
tmpFld = Trim(x_MXrecord)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("MXrecord") = tmpFld
tmpFld = Trim(x_Survey)
If Trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Survey") = tmpFld
tmpFld = x_sperrdatum
If IsDate(tmpFld) Then
rs("sperrdatum") = CDate(tmpFld)
Else
rs("sperrdatum") = Null
End If
rs.Update
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing



and now i want to do the following:
----------------------------------------------------------------------------------------------------
if the field "Inhaber = Rechnungsadresse" is true, which means

if the "Inhaberadress" is the same as the "Rechnungsadress"


<td bgcolor="#0099CC" class="aspmaker" style="color: #FFFFFF">Inhaber=Rechnungsadresse</td>
<td bgcolor="#F5F5F5"><font class="aspmaker">
<input type="radio" name="x_InhRe">
<%= "Ja" %>
<input type="radio" name="x_InhRe">
<%= "Nein" %></font>&nbsp;</td>


the input be automatically inserted into the DB on both fields, which means, if the Inhaber Entrys are the same as the Rechnungsadresse Entry all Datas shoud be automatically filled in on both --> time saving for typing



how can do this?

best regards

E.Altherr
 
your code sould use some severe dynamics, would cut down on alot of visible code, and in turn save you some debugging issues in the future should you happen to change your code a little... and the item you added at the end to try and save you some typing, is also added at the end to make it work out.

Code:
<%
'[green] Open Connection to the database[/green]
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str
Select Case a
     Case "C": '[green] Get a record to display[/green]
          tkey = "" & key & ""
          strsql = "SELECT * FROM [Kunden] WHERE [ID]=" & tkey
          Set rs = Server.CreateObject("ADODB.Recordset")
          rs.Open strsql, conn
          If rs.Eof Then
               Response.Clear
               Response.Redirect "Kundenlist.asp"
          Else
               rs.MoveFirst
      			   '[green] cycle through the recordset fields[/green]
      			   for each field in rs.fields
      		       '[green] this line sets the fieldname = fieldvalue as your block of statements used to.[/green]
      			     Execute("x_" & field.name & "=" & rs(Field.name))
               Next
          End If
          rs.Close
          Set rs = Nothing
     Case "A": '[green] Add
          ' Open record[/green]
          strsql = "SELECT * FROM [Kunden] WHERE 0 = 1"
          Set rs = Server.CreateObject("ADODB.Recordset")
          rs.Open strsql, conn, 1, 2
          rs.AddNew
          tmpFld = x_ID
          If Not IsNumeric(tmpFld) Then tmpFld = 0
          srchFld = tmpFld
          strsql = "SELECT * FROM [Kunden] WHERE [ID] = " & srchFld
          Set rschk = conn.Execute(strsql)
          If Not rschk.Eof Then
            Response.Write "Achtung doppelte Laufnummer -- ID, value = " & tmpFld & "<br>"
            Response.Write "Im Browser auf zurückklicken und nochmals versuchen!"
            Response.End
          End If
          rschk.Close
          Set rschk = Nothing
          '[green]Specially handled fields : [/green]
          TrueFalseFields = Split("Reseller,gesperrt,Kontrolliert",",")
          DateFields = Split("sperrdatum",",")
          '[green] cycles through all the form elements and makes variables by the same name.[/green]
          '[green] plus checks for handling of prenoted fields above, RS(ID) is handled as part of the sequence[/green]
          '[green] for checkbox reliability this might be wise to flip to a for each field in rs.fields instead of relying on the form object.[/green]
          for each item in request.form
            Field = Replace(item,"x_","")
            tmpFld = Trim(request(item))
            If ChkArray(TrueFalseFields,Field) Then '[green] checks for true false formatted fields[/green]
                If tmpFld = "1" Then
                    rs(Field) = True
                Else
                    rs(Field) = False
                End If
            ElseIf ChkArray(DateFields,Field) Then '[green] checks for date formatted fields [/green]
                If IsDate(tmpFld) Then
                    rs(Field) = CDate(tmpFld)
                Else
                    rs(Field) = Null
                End If
            Else
                If tmpFld = "" then 
                    tmpFld = Null
                End If
                RS(Field) = tmpfld
            End If
          next

          rs.Update
          rs.Close
          Set rs = Nothing
          conn.Close
          Set conn = Nothing


Function ChkArray(Values,Value) '[green]returns true/false on a comparitive set[/green]
    ChkArrayArr = Values
    ChkArray = False
    For ChkArrayArrCounter=0 to Ubound(ChkArrayArr)
        If StrComp(ChkArrayArr(ChkArrayArrCounter),Value,vbTextCompare)=0 Then
            ChkArray = True
        End If
    Next
End Function

%>

and the radio update :

Code:
<td bgcolor="#0099CC" class="aspmaker" style="color: #FFFFFF">Inhaber=Rechnungsadresse</td>
  <td bgcolor="#F5F5F5"><font class="aspmaker">
    <input type="radio" name="x_InhRe" value=1>
    <%= "Ja" %>
    <input type="radio" name="x_InhRe" value=0>
    <%= "Nein" %></font>&nbsp;</td>

[thumbsup2]DreX
aKa - Robert
 
here's the changed code for that last cycle :

Code:
          '[green] cycles through all the form elements and makes variables by the same name.[/green]
          '[green] plus checks for handling of prenoted fields above, RS(ID) is handled as part of the sequence[/green]
          '[green] for checkbox reliability this might be wise to flip to a for each field in rs.fields instead of relying on the form object.[/green]
          for Field in RS.Fields
            tmpFld = Trim(request("x_" & field.Name))
            If ChkArray(TrueFalseFields,Field.Name) Then '[green] checks for true false formatted fields[/green]
                If tmpFld = "1" Then
                    rs(Field.Name) = True
                Else
                    rs(Field.name) = False
                End If
            ElseIf ChkArray(DateFields,Field.Name) Then '[green] checks for date formatted fields [/green]
                If IsDate(tmpFld) Then
                    rs(Field.Name) = CDate(tmpFld)
                Else
                    rs(Field.Name) = Null
                End If
            Else
                If tmpFld = "" then 
                    tmpFld = Null
                End If
                RS(Field.Name) = tmpfld
            End If
          next

          rs.Update
          rs.Close
          Set rs = Nothing
          conn.Close
          Set conn = Nothing

[thumbsup2]DreX
aKa - Robert
 
Hi DreX (Robert)

Well i tested your code but it doesn't work, a 500'er Error occurs if i want to open the modified page?

question:

i removed also the statement below: is that ok?
or coud this cause the 500 Error?

------------------------------------------------------------
' Get fields from form
x_ID = Request.Form("x_ID")
x_Domain = Request.Form("x_Domain")
x_TLD = Request.Form("x_TLD")
x_LoginName = Request.Form("x_LoginName")
x_Passwort = Request.Form("x_Passwort")
x_Service = Request.Form("x_Service")
x_Kundennummer = Request.Form("x_Kundennummer")
x_FK_ID_Server = Request.Form("x_FK_ID_Server")
x_Erfasst_am = Request.Form("x_Erfasst_am")
x_gesperrt = Request.Form("x_gesperrt")
x_Bemerkungen = Request.Form("x_Bemerkungen")
x_alte_infos = Request.Form("x_alte_infos")
x_alg_infos = Request.Form("x_alg_infos")
x_best_anm = Request.Form("x_best_anm")
x_Reseller = Request.Form("x_Reseller")
x_Reseller_nummer = Request.Form("x_Reseller_nummer")
x_Anrede_best = Request.Form("x_Anrede_best")
x_Firma_best = Request.Form("x_Firma_best")
x_Nname_best = Request.Form("x_Nname_best")
x_Vorname_best = Request.Form("x_Vorname_best")
x_Strasse_best = Request.Form("x_Strasse_best")
x_Postfach_best = Request.Form("x_Postfach_best")
x_PLZ_best = Request.Form("x_PLZ_best")
x_Ort_best = Request.Form("x_Ort_best")
x_Telefon_best = Request.Form("x_Telefon_best")
x_Fax_best = Request.Form("x_Fax_best")
x_Land_best = Request.Form("x_Land_best")
x_Email_best = Request.Form("x_Email_best")
x_Anrede_re = Request.Form("x_Anrede_re")
x_Firma_re = Request.Form("x_Firma_re")
x_Nname_re = Request.Form("x_Nname_re")
x_Vorname_re = Request.Form("x_Vorname_re")
x_Strasse_re = Request.Form("x_Strasse_re")
x_Postfach_re = Request.Form("x_Postfach_re")
x_PLZ_re = Request.Form("x_PLZ_re")
x_Ort_re = Request.Form("x_Ort_re")
x_Telefon_re = Request.Form("x_Telefon_re")
x_Fax_re = Request.Form("x_Fax_re")
x_Land_re = Request.Form("x_Land_re")
x_Email_re = Request.Form("x_Email_re")
x_Anrede_tec = Request.Form("x_Anrede_tec")
x_Firma_tec = Request.Form("x_Firma_tec")
x_Nname_tec = Request.Form("x_Nname_tec")
x_Vorname_tec = Request.Form("x_Vorname_tec")
x_Strasse_tec = Request.Form("x_Strasse_tec")
x_Postfach_tec = Request.Form("x_Postfach_tec")
x_PLZ_tec = Request.Form("x_PLZ_tec")
x_Ort_tec = Request.Form("x_Ort_tec")
x_Telefon_tec = Request.Form("x_Telefon_tec")
x_Fax_tec = Request.Form("x_Fax_tec")
x_Land_tec = Request.Form("x_Land_tec")
x_Email_tec = Request.Form("x_Email_tec")
x_Kontrolliert = Request.Form("x_Kontrolliert")
x_erfasst_durch = Request.Form("x_erfasst_durch")
x_MXrecord = Request.Form("x_MXrecord")
x_Survey = Request.Form("x_Survey")
x_sperrdatum = Request.Form("x_sperrdatum")
x_Domainreg = Request.Form("x_Domainreg")
x_InhRe = Request.Form("x_InhRe")
------------------------------------------------------------

thanks for your help

best regards

E.Altherr

 
Hi DreX (Robert)

Well i found now why (after i modified my asp page to your recommandations) the error 500 appears:

if put


Else
rs.MoveFirst
' cycle through the recordset fields
for each field in rs.fields

in my page (i don't know why) after i put the code above in the source the error 500 appears

thanks for your help


 
personally i would remove the rs.movefirst, there's no real need for it ... at that point in the code you're already at the beginning of the recordset

that may be the cause

also this environment is based around the dynamics of VB, you wont be able to run option explicit without adding some addition execute statements into the mix in order to dim all the variables.

[thumbsup2]DreX
aKa - Robert
 
Well it work nearby, but the error 500 will occur, if i press the "Hinzufügen" Button, so i think the code error reside in the "update" area, which means, if the asp page tries to insert data in the Database, and i don't know why

here is the modified code:

------------------------------------------------------------
Select Case a
Case "C": ' Get a record to display
tkey = "" & key & ""
strsql = "SELECT * FROM [Kunden] WHERE [ID]=" & tkey
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn
If rs.Eof Then
Response.Clear
Response.Redirect "Kundenlist.asp"
Else
for each field in rs.fields
Execute("x_" & field.name & "=" & rs(field.name))
Next
End If
rs.Close
Set rs = Nothing
Case "A": ' Add

' Open record
strsql = "SELECT * FROM [Kunden] WHERE 0 = 1"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 1, 2
rs.AddNew
tmpFld = x_ID
If Not IsNumeric(tmpFld) Then tmpFld = 0
srchFld = tmpFld
strsql = "SELECT * FROM [Kunden] WHERE [ID] = " & srchFld
Set rschk = conn.Execute(strsql)
If Not rschk.Eof Then
Response.Write "Achtung doppelte Laufnummer -- ID, value = " & tmpFld & "<br>"
Response.Write "Im Browser auf zurückklicken und nochmals versuchen!"
Response.End
End If
rschk.Close
Set rschk = Nothing
TrueFalseFields = Split("Reseller,gesperrt,Kontrolliert",",")
DateFields = Split("sperrdatum",",")
for each item in request.form
Field = Replace(item,"x_","")
tmpFld = Trim(request(item))
If ChkArray(TrueFalseFields,Field) Then
If tmpFld = "1" Then
rs(Field) = True
Else
rs(Field) = False
End If
ElseIf ChkArray(DateFields,Field) Then
If IsDate(tmpFld) Then
rs(Field) = CDate(tmpFld)
Else
rs(Field) = Null
End If
Else
If tmpFld = "" then
tmpFld = Null
End If
RS(Field) = tmpfld
End If
next
rs.Update
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing

Function ChkArray(Values,Value)
ChkArrayArr = Values
ChkArray = False
For ChkArrayArrCounter=0 to Ubound(ChkArrayArr)
If StrComp(ChkArrayArr(ChkArrayArrCounter),Value,vbTextCompare)=0 Then
ChkArray = True
End If
Next
End Function

------------------------------------------------------------

many thanks for your trouble
and happy weekend

Greetings

Elvis
 
can you response out the sql statement and post it to look for errors?

[thumbsup2]DreX
aKa - Robert
 
you mean your modified sql statement

i will test in in the query analyzer and see if there is an error

 
i found that the "SQL Profiler" is a handy tool to determine where eventually the error is located

here is the output
-----------------------------------------------------------
[Microsoft][ODBC SQL Server Driver][SQL Server]Zeile 1: Falsche Syntax in der Nähe von '='. (Status 42000) (Code 170)
------------------------------------------------------------

so i think the error is maybe in this line:

strsql = "SELECT * FROM [Kunden] WHERE 0 = 1"



but i'm not shure

 
0 = 1 ?
check your sql statement for field names

[thumbsup2]DreX
aKa - Robert
 
sorry, but what you mean about check your sql statement for field names
 
SELECT * FROM [Kunden] WHERE 0 = 1
----------------^ Table Name .. is this correct?
----------------------------^^^^^ do you have a field ( COLUMN) in your table named 0? if yes, you'll need to refer to this field as [0] otherwise verify / change to the name of the field that SHOULD be there

[thumbsup2]DreX
aKa - Robert
 
looks like that zero needs to be [ID]

[thumbsup2]DreX
aKa - Robert
 
Hi DreX

sorry for my late reply, but i was in holiday last three weeks

Well i found now another solution to fill the fields (clientside scripting) if the radio button "Inhaber=Rechnungsadresse" is True

Thanks anyway for your help

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top