Solved

conntecting asp with sql serever

Posted on 2001-09-06
5
258 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Author Comment

by:saria
ID: 6460455
thenks
0
 
LVL 7

Accepted Solution

by:
John844 earned 50 total points
ID: 6460649
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
ID: 6460662
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
ID: 6466576
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
ID: 6722338
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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

729 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