|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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! |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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! |
|
#4
|
|||
|
|||
|
The path information to the .mdb file is stored in the system DSN you're using right now.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > creating a new database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|