Solved

conntecting asp with sql serever

Posted on 2001-09-06
5
249 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

26 Experts available now in Live!

Get 1:1 Help Now