Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Ado Delete in ASP

Ado Delete in ASP

To delete records using ADO in Classic ASP, you can use either a simple SQL string with Connection.Execute, or a parameterized query using ADODB.Command.


? 1. Simple DELETE Using Connection.Execute

<%Dim conn, sql, userIduserId = 5 ' Example: delete user with ID 5Set conn = Server.CreateObject("ADODB.Connection")conn.Open "Provider=SQLOLEDB;Data Source=SERVER;Initial Catalog=DB;User ID=USER;Password=PASS;"sql = "DELETE FROM Users WHERE UserID = " & userIdconn.Execute sqlconn.CloseSet conn = Nothing%>

?? Security Warning: Avoid directly inserting user input into SQL like above — it's vulnerable to SQL Injection.


? 2. Secure DELETE Using ADODB.Command (Parameterized Query)

<%Dim conn, cmd, userIduserId = 5Set conn = Server.CreateObject("ADODB.Connection")conn.Open "Provider=SQLOLEDB;Data Source=SERVER;Initial Catalog=DB;User ID=USER;Password=PASS;"Set cmd = Server.CreateObject("ADODB.Command")Set cmd.ActiveConnection = conncmd.CommandText = "DELETE FROM Users WHERE UserID = ?"cmd.CommandType = 1 ' adCmdTextcmd.Parameters.Append cmd.CreateParameter("UserID", 3, 1, , userId) ' 3 = adInteger, 1 = adParamInputcmd.ExecuteSet cmd = Nothingconn.CloseSet conn = Nothing%>

? Notes

  • Use adInteger = 3 for integer ID values.

  • Use ? placeholders and bind parameters in order.

  • cmd.Execute is fine for DELETE, INSERT, UPDATE (returns number of affected rows, optionally).


Let me know if you want this example adjusted for SQL Server, Access, or MySQL, or if you're deleting based on something other than an ID (e.g., email).

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql