Solved

conntecting asp with sql serever

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Microsoft SQL ADO Conn Issue 6 64
Html fieldset fix its height and width 4 55
Use Mid in Html 6 35
VB script help 23 50
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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

737 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