Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Up System DSN in Win2000 pro desktop m/c.

Status
Not open for further replies.

sqlovice

Programmer
Apr 20, 2002
2
GB
I need to transfer all my access data into an SQL Server db for a client but have not used SQL before. I have obtained the Microsoft Eval copy of SQL 2000 (v7), have installed it and got my data into a new database within my new SQL server application. Great, BUT....how can I get my system DSN to work in my ASP. the area where it is phasing me is the security side and log ins. I want it so anybody can get into the data (only via my ASP of course). I used to do this in ACCESS by simply putting UID and PWD values in my OPEN statement.

Could somebody help me please.

Rob Tabberner (rob@tabberner.com)
 
It would probably be more practical to use a "dsn-less" connection string as follows:

'db.asp
<%
dim db
dim objConn

objConn = &quot;DRIVER=SQL Server;SERVER=servername;UID=blah;PWD=blah;APP=Microsoft Development Environment;DATABASE=database_name;Address=servername&quot;
Set db = Server.CreateObject(&quot;ADODB.Connection&quot;)
db.open objConn
%>

You can save this in a separate file called &quot;db.asp&quot; then put this code at the top of your ASP:

<!-- #include file=&quot;db.asp&quot; -->
(be sure to include the correct path if it's not in the same folder as your ASP page)

Certain database activities require the below file as well:

<!-- #include file=&quot;adovbs.inc&quot; -->

Then you can do whatever with your data. Here's an example:

'select all information from Contacts

Set oRs = db.Execute(&quot;SELECT * FROM Contacts&quot;)
'check to see if records are found
if oRs.eof then
Response.Write &quot;No Records Found&quot;
else
Response.Write &quot;<table>&quot;
For Each oFLD In oRs.Fields
Response.Write &quot;<tr><td>&quot; & oFLD.Name & &quot;:<td><input type=&quot;&quot;text&quot;&quot; size=&quot;&quot;70&quot;&quot; name=&quot;&quot;&quot; & oFLD.Name & &quot;&quot;&quot; value=&quot;&quot;&quot; & oFLD.Value & &quot;&quot;&quot;/></td></td></tr>&quot;
Next
Response.Write &quot;</table>&quot;
end if

All this does is write out all of fields in the table Contacts.

Hope this helps.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top