SQL to ASP Converter
Transform SQL database dumps into ASP/VBScript code with arrays, ADODB recordsets, and dictionaries for classic ASP applications
SQL Input
ASP Output
About SQL to ASP Converter
Convert SQL database dumps (CREATE TABLE and INSERT statements) to ASP/VBScript code for use in classic ASP applications. This tool generates properly formatted VBScript code with arrays, ADODB recordsets, and dictionaries, making it easy to work with database data in your ASP projects.
Key Features
- Multiple Output Formats: 2D Arrays, ADODB Recordsets, or Array of Dictionaries
- VBScript Tags: Optional <% %> tags for direct use in ASP pages
- Usage Comments: Includes helpful code examples
- Type Handling: Proper handling of strings, numbers, booleans, and null values
- Recordset Support: Generate ADODB.Recordset objects
- Dictionary Support: Create Scripting.Dictionary objects
- Smart Parsing: Extracts column names and data from SQL dumps
- File Download: Save as .asp file
How to Use
- Input SQL Data: Paste your SQL CREATE TABLE and INSERT statements or upload a .sql file
- Choose Format: Select 2D Array, ADODB Recordset, or Dictionary format
- Configure Options: Enable VBScript tags and comments as needed
- Copy or Download: Use the Copy or Download button to save your ASP code
Output Formats
2D Array:
- Simple two-dimensional array structure
- Lightweight and fast
- Access data by index: data(row, column)
- Best for simple data storage
ADODB Recordset:
- Full-featured database recordset object
- Supports navigation (MoveFirst, MoveNext, etc.)
- Access data by field name: rs("fieldname")
- Perfect for database-like operations
- Compatible with existing ASP database code
Array of Dictionaries:
- Each row is a Dictionary object with named keys
- Easy to read and maintain
- Access data by key: data(index)("key")
- Flexible and intuitive
Example Conversion
SQL Input:
CREATE TABLE products ( id INT, name VARCHAR(100), price DECIMAL(10,2), inStock BOOLEAN ); INSERT INTO products VALUES (1, 'Laptop', 999.99, true); INSERT INTO products VALUES (2, 'Mouse', 24.99, true);
ASP Output (2D Array):
<% ' products data Dim productsData(1, 3) ' Column names: id, name, price, inStock productsData(0, 0) = 1 productsData(0, 1) = "Laptop" productsData(0, 2) = 999.99 productsData(0, 3) = True productsData(1, 0) = 2 productsData(1, 1) = "Mouse" productsData(1, 2) = 24.99 productsData(1, 3) = True ' Usage: value = productsData(row, column) %>
ASP Output (ADODB Recordset):
<%
' Create and populate recordset
Dim productsRS
Set productsRS = Server.CreateObject("ADODB.Recordset")
productsRS.Fields.Append "id", adVarChar, 255
productsRS.Fields.Append "name", adVarChar, 255
productsRS.Fields.Append "price", adVarChar, 255
productsRS.Fields.Append "inStock", adVarChar, 255
productsRS.Open
productsRS.AddNew
productsRS("id") = 1
productsRS("name") = "Laptop"
productsRS("price") = 999.99
productsRS("inStock") = True
productsRS.Update
productsRS.MoveFirst
' Usage:
' Do While Not productsRS.EOF
' Response.Write productsRS("id") & "<br>"
' productsRS.MoveNext
' Loop
%> Common Use Cases
- Legacy Applications: Maintain classic ASP applications
- Data Migration: Convert database data to ASP format
- Testing: Generate test data for ASP applications
- Prototyping: Quick data structures for development
- Static Data: Embed lookup tables and configuration data
- Offline Data: Work with data without database connection
VBScript Data Types
- String: Text values in double quotes
- Number: Integer and decimal values
- Boolean: True or False values
- Null: Empty or NULL values
ADODB Recordset Methods
- AddNew: Create a new record
- Update: Save changes to current record
- MoveFirst: Move to first record
- MoveNext: Move to next record
- EOF: Check if at end of recordset
- Close: Close the recordset
Scripting.Dictionary Methods
- Add: Add a key-value pair
- Item: Get or set value by key
- Exists: Check if key exists
- Remove: Remove a key-value pair
- Keys: Get array of all keys
Supported SQL Syntax
- CREATE TABLE: Extracts column names for field names
- INSERT INTO: Parses data values from INSERT statements
- Data Types: Handles all SQL data types (VARCHAR, INT, DECIMAL, BOOLEAN, etc.)
- Quoted Strings: Handles single and double quotes with proper escaping
- NULL Values: Converts to VBScript Null
Classic ASP Best Practices
- Use Recordsets for Database-like Data: Provides familiar interface
- Use Arrays for Simple Data: Faster and more memory efficient
- Use Dictionaries for Named Access: More readable code
- Always Close Recordsets: Free up resources
- Set Objects to Nothing: Release memory
Privacy & Security
All conversions happen locally in your browser. Your SQL data is never uploaded to any server, ensuring complete privacy and security.
