ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 9th, 2003, 08:35 AM
aspuser25 aspuser25 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 141 aspuser25 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
creating a new database

hi...

While developing the website, i had created a database. it was residing in a path "c:\program files\blah..blah...". While working with access i never specified the path in my code...it automatically picked up the values from the table.

Now i wanted to create tables for my database all over again. SO i plan to create another database with teh same tables but with slight definition change.

My query is now i plan to create database in the inetpub folder where all my code is residing. So how will the code now recognize from where to pick the values? as the database name will be the same??? so then will i need to specify the path in my code? if yes how had it been working till now?

taking a simple example of a testconnect database code..i never gave the path anywhere???? ===>
<%
DIM SQL
DIM RSA
DIM BGC
set RSA = Server.CreateObject("ADODB.Recordset")
RSA.OPEN "SELECT * FROM TEST", "DSN=school"
'If not RSA.EOF and not RSA.BOF then
Do while not RSA.EOF
'rsa.movefirst
Response.Write "<table>"
Response.Write "<tr>"
Response.Write "<td bgcolor=" & BGC & "> " & RSA.Fields ("name").Value & "</td>"
Response.Write "<td bgcolor=" & BGC & "> " & RSA.Fields ("age").Value & "</td>"
Response.Write "</tr>"
Response.Write "</table>"
rsa.movenext
loop
'end if
%>
thanks!

Reply With Quote
  #2  
Old September 9th, 2003, 08:49 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Look at it this way...

You have an inetpub folder, inside that folder, you have a wwwroot folder.

Now create a folder called test for example inside the wwwroot. You should now have something like:

inetpub --> wwwroot --> test

Inside test, place your .mdf(Access database) file.
Then create a simple .asp(Active Server Page) file, call it mytest.asp

Inside mytest.asp do this:

<%@ Language=VBScript %>

<%
Const PATH = "C:\Inetpub\wwwroot\test\yourdb.mdf"
'NOTE: I've assumed that your inetpub folder was on the C:\ drive
'I've also assumed that your database file was named yourdb.mdf


Dim strSql
Dim objConn
Dim objRst

strSql = "SELECT * FROM Table"

Set objConn = Server.CreateObject("ADODB.Connection")

objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & PATH

Set objRst = objConn.execute strSql

If objRst.EOF Then

Response.Write "No data in the table"

Else

While NOT objRst.EOF

Response.Write objRst("Field1") & "<br>"

objRst.MoveNext
Wend

End If

objRst.Close
Set objRst = nothing

objConn.Close
Set objConn = nothing
%>


NOTE: There are *MANY* ways to do this, this is *NOT* necessarily the best way but it is a way...(before anyone shouts!)

Also note that in the PATH constant, I did NOT provide a username and/or password so be careful of that if you have one, you'll need to add it!

Hope this helps!
Sincerely

Vlince

Reply With Quote
  #3  
Old September 9th, 2003, 09:09 AM
aspuser25 aspuser25 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 141 aspuser25 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Thumbs up

thanks vlince it does help answer lot many doubts in my mind. but still i am unable to resolve one doubt? till now in my application i just didnt use any path? so why do i need to give right now? ok i understand that i need to tell the application from which database to pick the tables and then the values.

but how is it workign till now?????

how was it recognizing that till now my database path was "c:\program files\....." ???

thanks!

Reply With Quote
  #4  
Old September 9th, 2003, 10:50 AM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,843 Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 22 h 48 m 43 sec
Reputation Power: 766
The path information to the .mdb file is stored in the system DSN you're using right now.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > creating a new database


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway