'************************************** ' Name: SQL and ASP ' Description:SQL and ASP: Here I have listed same important SQL-Statement. and same functions for connect to Database. By my samples I don't use: follow ADO Command: -add -update ... only SQL (is faster and better to read) I dont't check why so much programmer use not the SQL-Staetment ' By: Hohl David (from psc cd) ' ' ' Inputs:None ' ' Returns:None ' 'Assumes:None ' 'Side Effects:None '************************************** 'SELECT with Array Dim arrstrZipcode() Dim i Set rec = Server.CreateObject("ADODB.Recordset") strSQL = "SELECT zipcode FROM ZIPCODES WHERE Countrycode = 'AUT'" set rec = objConn.Execute(strSQL) if not rec.eof then while not rec.eof redim preserve arrstrZipcode(i) arrstrZipcode(i) = rec.fields("zipcode") rec.movenext i = i + 1 wend else strError = "Nothing found" end if ' 覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 ' 'UPDATE strFirstname = ReplaceUnletters(Request.form("txtFirstname")) iAdressID = Request.Form("txtAdressID") Set rec = Server.CreateObject("ADODB.Recordset") strSQL = "Update ADDRESS SET " & _ "Firstname = '" & strFirstname & "' " & _ "WHERE ZipcodeID = " & iAdressID set rec = objConn.Execute(strSQL) ' 覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 ' 'INSERT strFirstname = ReplaceUnletters(Request.form("txtFirstname")) strLastname = ReplaceUnletters(Request.form("txtFirstname")) Set rec = Server.CreateObject("ADODB.Recordset") strSQL = "INSERT INTO ADDRESS (Firstname, Lastname) VALUES ( " & _ "'" & strFirstname & "', " & _ "'" & strLastname & "')" set rec = objConn.Execute(strSQL) ' 覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 ' 'DELETE iAddressID = Request.querystring("AdID") Set rec = Server.CreateObject("ADODB.Recordset") strSQL = "DELETE FROM ADDRESS WHERE AddressID = " & iAddressID set rec = objConn.Execute(strSQL) ' 覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 ' ' FUNCTIONS ' 覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 ' function OpenDatabase() Dim strDatabaseIP, strPW, strUID strDatabaseIP = "150.150.100.210" strPW = "" strUID = "sa" 'SQL-Server strConn = "Provider=SQLOLEDB.1;SERVER=" & strDatabaseIP & ";DATABASE=ADDRESS;UID=" & strUID & ";PWD=" & strPW 'MY SQL strConn = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=" & strDatabaseIP & ";DATABASE=Address;UID=" & strUID & ";PWD=" & strPW & ";OPTION=35;" set objConn = server.CreateObject("ADODB.Connection") objConn.Open(strConn) end function function CloseDatabase() objConn.close Set objConn = Nothing end function ' 覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 ' Public Function ReplaceUnLetters(ByVal strReplace) strReplace = Replace(strReplace, "'", "''") ReplaceUnLetters = strReplace End Function ' 覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 ' Function ReplaceNonSpace(strText) 'Here I want replace HTMLSPACE WITH norm ' al space, but the insert into the Planet ' Source code replace the HTML TAG excuse ReplaceNonSpace = Replace(strText, "", " " ) End Function