Files
shopdb/docs/ASP_DEVELOPMENT_GUIDE.md
cproudlock e598f72616 Remove emojis from all markdown docs, add consolidation plan
- Strip emojis from 47 markdown files across docs/, sql/, and root
- Add docs/DOCS_CONSOLIDATION_PLAN.md with plan to reduce 45 docs to 8
- Establish no-emoji rule for documentation going forward

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 07:42:52 -05:00

587 lines
14 KiB
Markdown

# Classic ASP/VBScript Development Guide
## Overview
**shopdb** is a Classic ASP application using VBScript running on IIS Express in Windows 11 VM.
- **Language:** VBScript (Classic ASP)
- **Server:** IIS Express (Windows 11 VM)
- **Database:** MySQL 5.6 (Docker container on Linux host)
- **Development:** Edit files on Linux with Claude Code, test on Windows/IIS
## Project Setup
### Location
- **Linux:** `~/projects/windows/shopdb/`
- **Windows:** `Z:\shopdb\`
- **IIS Config:** Points to `Z:\shopdb\`
### Database Connection
```vbscript
<%
' Connection string for shopdb
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = "Driver={MySQL ODBC 8.0 Driver};" & _
"Server=192.168.122.1;" & _
"Port=3306;" & _
"Database=shopdb;" & _
"User=570005354;" & _
"Password=570005354;" & _
"Option=3;"
conn.Open
' Use the connection
' ... your code here ...
conn.Close
Set conn = Nothing
%>
```
## Database Credentials
**Production Database: shopdb**
- **Host (from Windows):** 192.168.122.1
- **Port:** 3306
- **Database:** shopdb
- **User:** 570005354
- **Password:** 570005354
## Prerequisites in Windows VM
### Required Software
1. **MySQL ODBC 8.0 Driver**
- Download: https://dev.mysql.com/downloads/connector/odbc/
- Install 64-bit version
- Used by Classic ASP to connect to MySQL
2. **IIS Express**
- Already installed
- Location: `C:\Program Files\IIS Express\`
### Windows Configuration
- **Z: Drive** mapped to `\\192.168.122.1\windows-projects`
- **Firewall** allows port 8080 inbound
- **URL ACL** configured: `netsh http add urlacl url=http://*:8080/ user="Everyone"`
### Auto-Start IIS Express on Windows Boot
To automatically start IIS Express when Windows boots:
1. **In Windows, open Task Scheduler** (search for "Task Scheduler")
2. **Create a new task:**
- Click "Create Task..." (not "Create Basic Task")
- **General tab:**
- Name: `Start IIS Express - shopdb`
- Description: `Auto-start IIS Express for shopdb site`
- Check "Run with highest privileges"
- Check "Run whether user is logged on or not"
- Configure for: Windows 10/11
- **Triggers tab:**
- Click "New..."
- Begin the task: "At startup"
- Delay task for: 30 seconds (gives network time to connect)
- Click OK
- **Actions tab:**
- Click "New..."
- Action: "Start a program"
- Program/script: `wscript.exe`
- Add arguments: `Z:\start-iis-shopdb.vbs`
- Click OK
- **Conditions tab:**
- Uncheck "Start the task only if the computer is on AC power"
- Check "Wake the computer to run this task" (optional)
- **Settings tab:**
- Check "Allow task to be run on demand"
- Check "Run task as soon as possible after a scheduled start is missed"
- If the task is already running: "Do not start a new instance"
- Click OK to save
3. **Test the task:**
- Right-click the task in Task Scheduler
- Click "Run"
- Check http://localhost:8080 in browser
- Should see shopdb running
4. **Verify on next boot:**
- Restart Windows VM
- Wait 30 seconds after login
- Check http://192.168.122.151:8080 from Linux
- IIS Express should be running automatically
**Files Created:**
- `Z:\start-iis-shopdb.bat` - Batch file to start IIS Express
- `Z:\start-iis-shopdb.vbs` - VBScript wrapper (runs silently, no console window)
**Manual Start (if needed):**
```powershell
# In Windows, double-click:
Z:\start-iis-shopdb.vbs
# Or run from PowerShell:
wscript.exe Z:\start-iis-shopdb.vbs
```
## Development Workflow
### 1. Edit Code on Linux
```bash
# Navigate to project
cd ~/projects/windows/shopdb
# Start Claude Code
claude
# Ask Claude to help with your ASP/VBScript code
# Example: "Create a VBScript function to query the database and display results"
```
### 2. Files Auto-Sync to Windows
- Any changes saved on Linux automatically appear in Windows at `Z:\shopdb\`
- No manual copying needed thanks to Samba share
### 3. Test on IIS Express
**In Windows PowerShell (as Administrator or with URL ACL):**
```powershell
cd "C:\Program Files\IIS Express"
.\iisexpress.exe /site:shopdb
```
**Access from Linux:**
- Browser: http://192.168.122.151:8080
**Access from Windows:**
- Browser: http://localhost:8080
### 4. Iterate
- Edit on Linux with Claude
- Refresh browser to see changes
- Debug and repeat
## Common VBScript/ASP Patterns
### Database Query (SELECT)
```vbscript
<%
Dim conn, rs, sql
Set conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
conn.ConnectionString = "Driver={MySQL ODBC 8.0 Driver};Server=192.168.122.1;Port=3306;Database=shopdb;User=570005354;Password=570005354;"
conn.Open
sql = "SELECT * FROM products WHERE category = ?"
rs.Open sql, conn
Do While Not rs.EOF
Response.Write rs("product_name") & "<br>"
rs.MoveNext
Loop
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
%>
```
### Database Insert
```vbscript
<%
Dim conn, sql
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = "Driver={MySQL ODBC 8.0 Driver};Server=192.168.122.1;Port=3306;Database=shopdb;User=570005354;Password=570005354;"
conn.Open
sql = "INSERT INTO orders (customer_id, order_date, total) VALUES (1, NOW(), 99.99)"
conn.Execute sql
conn.Close
Set conn = Nothing
Response.Write "Order inserted successfully"
%>
```
### Database Update
```vbscript
<%
Dim conn, sql, orderId
orderId = Request.Form("order_id")
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = "Driver={MySQL ODBC 8.0 Driver};Server=192.168.122.1;Port=3306;Database=shopdb;User=570005354;Password=570005354;"
conn.Open
sql = "UPDATE orders SET status = 'completed' WHERE order_id = " & orderId
conn.Execute sql
conn.Close
Set conn = Nothing
Response.Redirect "orders.asp"
%>
```
### Form Handling
```vbscript
<%
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
' Handle form submission
Dim name, email
name = Request.Form("name")
email = Request.Form("email")
' Validate and process
' ...
Response.Write "Form submitted successfully"
Else
' Display form
%>
<form method="post" action="submit.asp">
<input type="text" name="name" required>
<input type="email" name="email" required>
<button type="submit">Submit</button>
</form>
<%
End If
%>
```
### Include Files
```vbscript
<!-- #include file="config.asp" -->
<!-- #include file="header.asp" -->
<% ' Your page content here %>
<!-- #include file="footer.asp" -->
```
### Session Management
```vbscript
<%
' Set session variable
Session("user_id") = 123
Session("username") = "admin"
' Get session variable
If Session("user_id") <> "" Then
Response.Write "Welcome, " & Session("username")
Else
Response.Redirect "login.asp"
End If
' Clear session
Session.Abandon
%>
```
## Connection File Template
**Create: `~/projects/windows/shopdb/includes/db_connection.asp`**
```vbscript
<%
' Database connection configuration
Function GetConnection()
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = "Driver={MySQL ODBC 8.0 Driver};" & _
"Server=192.168.122.1;" & _
"Port=3306;" & _
"Database=shopdb;" & _
"User=570005354;" & _
"Password=570005354;" & _
"Option=3;"
On Error Resume Next
conn.Open
If Err.Number <> 0 Then
Response.Write "Database connection failed: " & Err.Description
Response.End
End If
Set GetConnection = conn
End Function
%>
```
**Usage in other files:**
```vbscript
<!-- #include file="includes/db_connection.asp" -->
<%
Dim conn
Set conn = GetConnection()
' Use the connection
' ...
conn.Close
Set conn = Nothing
%>
```
## Testing Database Connection
**Create: `~/projects/windows/shopdb/test_connection.asp`**
```vbscript
<%@ Language=VBScript %>
<html>
<head>
<title>Database Connection Test</title>
</head>
<body>
<h1>MySQL Connection Test</h1>
<%
On Error Resume Next
Dim conn, rs
Set conn = Server.CreateObject("ADODB.Connection")
Response.Write "<p>Attempting to connect to shopdb...</p>"
conn.ConnectionString = "Driver={MySQL ODBC 8.0 Driver};" & _
"Server=192.168.122.1;" & _
"Port=3306;" & _
"Database=shopdb;" & _
"User=570005354;" & _
"Password=570005354;"
conn.Open
If Err.Number <> 0 Then
Response.Write "<p style='color:red;'><strong>Connection Failed!</strong></p>"
Response.Write "<p>Error: " & Err.Description & "</p>"
Else
Response.Write "<p style='color:green;'><strong>Connection Successful!</strong></p>"
' Test query
Set rs = conn.Execute("SELECT VERSION() as version, DATABASE() as db")
Response.Write "<p>MySQL Version: " & rs("version") & "</p>"
Response.Write "<p>Current Database: " & rs("db") & "</p>"
rs.Close
Set rs = Nothing
conn.Close
End If
Set conn = Nothing
%>
</body>
</html>
```
## Troubleshooting
### Can't Connect to MySQL
**Check from Windows PowerShell:**
```powershell
# Test network connectivity
Test-NetConnection -ComputerName 192.168.122.1 -Port 3306
# Should show: TcpTestSucceeded : True
```
**Check MySQL is running on Linux:**
```bash
docker ps | grep mysql
docker compose logs mysql
```
### ODBC Driver Not Found
**Error:** `[Microsoft][ODBC Driver Manager] Data source name not found`
**Solution:**
1. Install MySQL ODBC 8.0 Driver in Windows
2. Verify in Control Panel → Administrative Tools → ODBC Data Sources
3. Check driver name matches in connection string
### Permission Denied
**Error:** Access denied for user '570005354'
**Solution on Linux:**
```bash
# Re-grant permissions
docker exec -it dev-mysql mysql -u root -prootpassword -e "
GRANT ALL PRIVILEGES ON shopdb.* TO '570005354'@'%' IDENTIFIED BY '570005354';
FLUSH PRIVILEGES;
"
```
### IIS Express Won't Start
**Check:**
1. Another process using port 8080? Check Task Manager
2. URL ACL configured? Run as Admin or check: `netsh http show urlacl`
3. applicationhost.config correct? Check binding: `*:8080:*`
### Changes Not Appearing
**Solutions:**
1. Hard refresh browser: `Ctrl + F5`
2. Clear browser cache
3. Check file actually saved on Linux: `ls -la ~/projects/windows/shopdb/`
4. Check Samba: `sudo systemctl status smbd`
## MySQL 5.6 Limitations
Our MySQL version (5.6) doesn't support:
- JSON data type (use TEXT and parse)
- `CREATE USER IF NOT EXISTS` syntax
- Some newer functions
**User management in MySQL 5.6:**
```sql
-- Create/update user
GRANT ALL PRIVILEGES ON shopdb.* TO 'username'@'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
```
## Security Notes
**Development Environment Only**
These credentials are for DEVELOPMENT:
- User: 570005354
- Password: 570005354
**For Production:**
- Use strong, unique passwords
- Implement proper authentication
- Use SSL/TLS connections
- Restrict database access by IP
- Never commit credentials to Git
## Quick Commands Reference
### Start Development
```bash
# On Linux
~/start-dev-env.sh
# In Windows
cd "C:\Program Files\IIS Express"
.\iisexpress.exe /site:shopdb
# Open browser to: http://192.168.122.151:8080
```
### Edit Code
```bash
# On Linux
cd ~/projects/windows/shopdb
claude
```
### Check Database
```bash
# On Linux
docker exec -it dev-mysql mysql -u 570005354 -p570005354 shopdb
```
### Backup Database
```bash
# On Linux
docker exec dev-mysql mysqldump -u 570005354 -p570005354 shopdb > ~/backups/shopdb-$(date +%Y%m%d).sql
```
### Restore Database
```bash
# On Linux
docker exec -i dev-mysql mysql -u 570005354 -p570005354 shopdb < backup.sql
```
## Using Claude Code for ASP/VBScript
**Good Prompts:**
```
"Create a VBScript function to display all products from the database in an HTML table"
"Add error handling to this database query in Classic ASP"
"Create a login form in Classic ASP that checks credentials against the users table"
"Write VBScript code to handle a POST form submission and insert into database"
"Create a pagination system for displaying database results in Classic ASP"
```
**Be Specific:**
```
"I'm using Classic ASP with VBScript and MySQL 5.6. Create a page that..."
```
### Starting a Claude Code Session
When beginning work, tell Claude to "start up" or "let's start the dev environment". Claude will automatically:
1. Review all .md documentation files
2. Run `~/start-dev-env.sh` to start Docker containers and Windows VM
3. Check service status to ensure everything is running
4. Load the todo list to continue from where you left off
### Closing Out a Claude Code Session
When you're done working, tell Claude to "close out" or "we're closing out for now". Claude will automatically:
1. Update and consolidate the todo list with completed work
2. Mark completed phases/tasks
3. Run `~/stop-dev-env.sh` to properly shutdown the environment
4. Update relevant documentation
This ensures your development environment is properly shut down and all progress is tracked.
## Project Structure Example
```
shopdb/
├── index.asp # Homepage
├── test_connection.asp # Database test page
├── includes/
│ ├── db_connection.asp # Database connection function
│ ├── header.asp # Common header
│ └── footer.asp # Common footer
├── admin/
│ ├── login.asp # Admin login
│ └── dashboard.asp # Admin dashboard
├── css/
│ └── styles.css # Stylesheets
├── js/
│ └── scripts.js # JavaScript files
└── images/
└── logo.png # Images
```
## Additional Notes
- **No PHP on Windows** - PHP development is done via Docker/Nginx on Linux (port 8080)
- **ASP on Windows only** - Classic ASP runs on IIS Express in Windows VM
- **Database shared** - Both PHP (Docker) and ASP (Windows) can access the same MySQL
- **File editing** - Always edit on Linux with Claude Code, files sync automatically to Windows
---
**Technology Stack Summary:**
- Classic ASP with VBScript
- IIS Express on Windows 11
- MySQL 5.6 (Docker/Linux)
- Samba for file sharing
- Claude Code for development assistance