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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i connect to database

Status
Not open for further replies.

sim133

Technical User
Sep 14, 2004
85
US
i have an asp written a simple asp code to connect to the database in order to generate some reports. my question would be do i need to fulfil some kind of pre-requiernments for me to pull those data from the databse. eg. do i need to set up ODBC driver ? DNS name....
 
do a dsn-less connection, don't knw if you have the odbc driver but most likely do test and see
 
It is easiest to use Microsoft ActiveX Data Objects.

Do a search on this site or on google for ADO and you'll get all that you ever wanted to know.

The FAQs for this site have some good stuff.

I strongly recommend not using a DSN. You can put everything needed into an ADO "ConnectionString" and this will be a lot easier on you in the long run... especially if someone moves your site to another physical server machine.
 
here is a dsn-less conn ex

Code:
strDBPath = Server.MapPath("yourdb.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"

Set rs = conn.Execute("SELECT * FROM tblname")
 
Steven290, do i need to know the path for my database.
 
steven290 , I am using oracle database is the code differnet for oracle9i db.
 

"Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=Username;Pwd=asdasd;"

This part i do not really understand clearly, Server=OracleServer.world what is OracleServer.world is this the name for my DataBase or it is somethng else. can you help to clarify that for me.
 
so basically

its

Code:
strDBPath = Server.MapPath("yourdb.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=Username;Pwd=asdasd;" 
Set rs = conn.Execute("SELECT * FROM tblname")

just set your server, database, username and password
 

strDBPath = Server.MapPath("yourdb.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=Username;Pwd=asdasd;"
Set rs = conn.Execute("SELECT * FROM tblname")

Sorry steven290, i am still confused I am not sure if i need to have this code since i want to connect to oracle db
strDBPath = Server.MapPath("yourdb.mdb")
2) Is oracleServer my server name or Database name
3) Do i need to talk to IIS server admn to set up something
for me to get connected to the Database or is this something
i should know how to .
please help me to clarify those ambiguties since i am fairly new in using asp

thanks a bunch for the help




 
sim

databases and servers are 2 different devices entirely....

it says and take it literally>>>Server=(this is name of your SERVER)



Server.MapPath("(this is the name of your DATABASE.mdb")

if you don't have a setup on the server for permissions than yes you will need to get that unless you have admin right yurself and do it yourself

Brian
 
oooops..i see that ".mdb" (access) may confused you....again simply but the name of the ORACLE db here
 
Well if you are using Oracle then you won't need the .mdb file because that is for MS Access.... I probably didn't understand the question.
 
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=Username;Pwd=asdasd;"
Set rs = conn.Execute("SELECT * FROM tblname")

Thank you for clarification guys.Just out of curiousity how would it know to connect to the right database since we have more than one database on the server.
 
sorry i do know understand it clearly what do you mean try
server.database. you meant i should insert my database name.world instead of OracleServer.world
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top