Solved

conntecting asp with sql serever

Posted on 2001-09-06
5
248 Views
Last Modified: 2008-02-01
i have windows 2000 prof and sql serever 2000
i want to give me how i can conntected it?
and source code?
thanks
0
Comment
Question by:saria
5 Comments
 

Author Comment

by:saria
Comment Utility
thenks
0
 
LVL 7

Accepted Solution

by:
John844 earned 50 total points
Comment Utility
you need to use ado to connect to a db using an asp page.
a simple example would be something like

dim con
dim rs
dim strSQL

'define what data you wish to use
strSQL = "SELECT * FROM tableName"

'open a connection to the database
con.open <database connection string>

'open a recordset using the connection and SQL statement
rs.open strSQL, con, 3, 1

if rs.eof and rs.bof then
    response.write "No records returned.<br>"
else
    while not rs.eof
        'work with the data here
        'access the individual fields by placing their name in quotes like
        response.write rs("fieldName")
        rs.movenext
    loop
end if

rs.close
con.close

set rs = nothing
set con = nothing




Connection String
here is a link to help explain how to build a connection string
http://www.asp101.com/articles/john/connstring/default.asp

http://www.able-consulting.com/ADO_Conn.htm


if you want to use a DSN you can use
 con.open "FileDSN=SomeFileDSN"
or
 con.open "DSN=SomeSystemDSN"
or

0
 
LVL 19

Expert Comment

by:daveamour
Comment Utility
Dim objADOConnection
Dim rsData
Dim strSQL

Set objADOconnection = Server.CreateObject("ADODB.Connection")
Set rsData = Server.CreateObject("ADODB.Recordset")

objADOConnection.Open "PROVIDER=MSDASQL;DRIVER={SQL Server};SERVER=Servername;DATABASE=Databasename;UID=Username;PWD=Password"

strSQL = "Select * From tableName"

rsData.Open strSQL, objADOConnection

While Not rsData.EOF
  Response.Write rsData.Fields("Fieldname") & "<Br>"
  rsData.Movenext
Wend  

Replace teh following with values appropriate to your database


Servername
Databasename
Username
Password
tableName
Fieldname

Hope this helps

Dave
0
 
LVL 1

Expert Comment

by:Atsafrir
Comment Utility
if you are working with windows 2000 - com+ you can use the Component consturct string. there is a good
exapmle for this in Fitch & Marther DNA sample application.
http://www.fmstocks.com download FMSTOCKS source code.
good luck.
if you want my DAL (Data Access Layer) component send me your email and i'll send it to you (it's better
then fmstocks).
there is a nice tool that you can use to ceate stored procedures , and cls file in vb (from which you
an create your component) to call the stored procedure
it's a freeware from lockwoodtech.
http://www.lockwoodtech.com/index_pbfree.htm
http://www.lockwoodtech.com/zips/ProcBlastFree.exe
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
I am sorry to see that Asker has not returned to update and finalize this question.  I am, therefore, force accepting this question.  In the event the Asker returns with additional needs related to this question, please respond and continue the collaboration process.
 
If there are questions in this regard, please comment and I'll return when I can.
 
The HELP DESK link on the left is informative, and includes this site's Guidelines and Member Agreement as well as assistance related to Questions and Answers.  Here is the QA link, as a reference.
 
http://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp
 
Thank you,
Moondancer
Community Support Moderator @ Experts Exchange
 
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now