Page is a not externally linkable
- WebmasterWorld
-- New To Web Development
---- Connecting Classic ASP to Sql Express


mattur - 2:09 pm on Mar 9, 2009 (gmt 0)


ASP uses ADO to connect to databases. You just need an OLEDB connection string to connect to Sql Express. Something like:

Provider=SQLOLEDB.1;Data Source=*yourserver*;Initial Catalog=*yourdatabasename*;User ID=*youruserid*;Password=*yourpassword*;

And use ADO like:

<%
Const DB_CNN = "Provider=SQLOLEDB.1;Data Source=*yourserver*;Initial Catalog=*yourdatabasename*;User ID=*youruserid*;Password=*yourpassword*;"
Dim cnn,rst,sql
sql = "SELECT * FROM MyTable;"
Set cnn = Server.CreateObject("ADODB.Connection")
cnn.Open DB_CNN
Set rst = Server.CreateObject("ADODB.Recordset")
rst.Open sql, cnn
'
'do stuff with recordset
'
'IMPORTANT: always clean up afterwards
rst.Close
Set rst = Nothing
cnn.Close
Set cnn = Nothing
%>

Download SQL Server Management Studio Express to create and manage your database and tables.


Thread source:: http://www.webmasterworld.com/new_web_development/3866090.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com