læse fra 2 databaser
Jeg bruger dette script til at læse fra min DB.jeg har en anden DB som indeholder feltet 'skadenummer' og vil gerne læse fra den samtidig.
løsning er 150 point værd.
<%
' Henter værdien fra soeg.htm
strKeyword = Trim(Request.Form("Keyword"))
If Len(strKeyword) = 0 Then
' Hvis der ikke er skrevet i feltet
Response.Clear
Response.Redirect("kundesearch.htm")
Else
' Hvis der er skrevet i feltet
strKeyword = Replace(strKeyword,"'","''")
End If
' Opbygger en dynamisk SQL streng
strSQL = "SELECT TOP 1 ID, nummer, forhandlernavn, forhandleradr, forhandlerpostnr, forhandlerby, forhandlertele, kundenavn, kundeadr, kundepostnr, kundeby, kundetele, kundeemail, type, kundeudstyr, dato, kundefejl, kunderep, kundepris, status, datoslut, policenr, password, retur FROM database WHERE"
strSQL = strSQL & " (nummer LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (forhandlernavn LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (forhandleradr LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (policenr LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (forhandlerby LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (forhandlertele LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (kundenavn LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (kundeadr LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (kundepostnr LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (kundeby LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (kundetele LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (kundeemail LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (type LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (kundeudstyr LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (dato LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (kundefejl LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (datoslut LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (policenr LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (password LIKE '" & strKeyword & "')"
strSQL = strSQL & " OR (retur LIKE '" & strKeyword & "')"
strSQL = strSQL & " ORDER BY ID DESC"
' Skaber DSNLess forbindelse til DBen
strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\websider\service-info.dk\db\database.mdb"
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open strDSN
' Skaber et recordset udfra SQL strengen
Set rs = myConn.Execute(strSQL)
If Not (rs.BOF Or rs.EOF) Then
blabla
