Forum Moderators: open
<%
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "Provider=sqloledb;Data Source=ip address;Initial Catalog=dbname;User Id=#*$!;Password=#*$!x;"
%>
1. define a connection string depending on the driver and the database type.
You may find some strings here: [connectionstrings.com...]
2. create a connection object, for example
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
3. open the connection
objConn.Open strSQL
where strSQL is the connection string you defined before.
4. query the database
5. close and reset connection object.
Set objConn = Nothing
About the point number 4 it's to long to explain here in some lines.
You need to know something about SQL language to work with the database.
The link mattglet gave to you contains lots of interesting articles and information.
therefore is...
<%
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "Provider=sqloledb;Data Source=ip address;Initial Catalog=dbname;User Id=#*$!;Password=#*$!x;"
Set conn=nothing
%>
so far correct? or should conn be replaced with objconn?
Do i keep the above closed and then start a new
<%
%>
But call conn?
This is where i am stuck. Can you giva example?
...
' Create a recordset object
Set objRs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT fieldname FROM tablename"
objRs.Open strSQL, objConn
' do something
objRs.Close
Set objRs = Nothing
...
%>
This is SQL.
[w3schools.com...]
So far we are at:
<%
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "Provider=sqloledb;Data Source=ip address;Initial Catalog=dbname;User Id=#*$!;Password=#*$!x;"
set objRs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT fieldname FROM tablename"
objRs.Open strSQL, objConn
' do something
objRs.Close
Set objRs = Nothing
Set conn=nothing
%>
am i still correct? It the do something bit that it appears im stuck with.
I can't tell you what you need to put there because it depends what you want to do.
You may print all records, read some data, create an other query...
Before starting create something with ASP you need to know what you want to do.