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

database connection string for *.dbf file...

Status
Not open for further replies.

Ovatvvon

Programmer
Feb 1, 2001
1,514
US
Hi, I've been using the odbc connection for a dbf file for my .asp pages. Now I would like to use a written connection string, but can't figure out what the context would be.

In the odbc program, I select Microsoft dBase VPF Driver (*.dbf) from the list and with the configureation, I select Free Table Directory.

I tried typing "connString = "DRIVER={Microsoft dBase VPF Driver (*.dbf)};", but it won't work.

I need this quite urgently...if anyone can help, I'd really appreciate it!

Thanks in advance!!! -Ovatvvon :-Q
 
Ovattvon,

Read this post: thread333-144882

At first, Paul gives a pretty neat solution on how to generate DSNLess connection strings. However, we later determined that the tip wouldn't work for Fox Pro strings.

Therefore, scroll down to the bottom of the post and Paul gives specific DSNless connection string examples for Visual Fox Pro. I didn't test them, but he's one of the smartest guys on this forum so it's definitely worth the try.

Hope this helps.

TW
 
This works...however one question. I take it that it works because I only have one dbf file in my directory, because it doesn't specify which dbf file to use...a name or anything.

So, if I had more than one dbf file in that folder, how would it still pull the correct dbf file that I want to work with for the given page?

supplied info:
connString = "Driver={Microsoft Visual FoxPro Driver};" & _
"SourceType=DBF;" & _
"SourceDB=c:\Inetpub\dbf;" & _
"Exclusive=No;"
-Ovatvvon :-Q
 
That's because you don't create a connection to a specific table. You're creating a connection to a database container or directory with free tables in it. If you have more than one table in it, then you specify the table you want to access in your SQL statements. So if you have more than one table in that directory like users.dbf and administrators.dbf then your SQL statements define which table you want to access like this.


SELECT * FROM administrators WHERE name = 'Joe'


Even if you only have one table in the directory, you still have to name it in your SQL statements.

Let me know if you have any additional questions.

TW
 
Sorry, just wasn't thinkin for a bit. :)

Just one more problem I'm having...using the server.mappath with the connection of sourcedb.

Here is what I typed:
connString = "Driver={Microsoft Visual FoxPro Driver};" & _
"SourceType=DBF;" & _
"SourceDB=" & Server.mappath("../db") & ";" & _
"Exclusive=No;"


but this won't make a connection to the database. The dbf file is in my c:\inetpub\dbf\db\ folder. The connection file is in my c:\inetpub\dbf\include\ folder. so it should go back out one folder and point into the db folder for the dbf file.

does this make sense? do you know why it isn't working? -Ovatvvon :-Q
 
I don't use Server.mappath in my application because I host my own web site on the server. You only need server.mappath if you don't know the physical location of the directory. Which, if you move your application to a host, you probably won't. But if you are going to keep your web site on a server where you will know the physical location of the directory, you don't need to use this method. At any rate, I don't know why you're having your problem but I will suggest a way to troubleshoot it to figure it out.

Create a test.asp page and put the following lines at the top.

<%@ Language=VBScript %>
<%
Response.Write server.mappath(&quot;something&quot;)
%>

Play around with that file until you get the correct path to the directory, then transfer it to your connection string.

TW
 
The funny thing is...is that I printed the server.mappath results directly from the connection.asp page when I went directly there to see what it was using. (response.write(server.mappath(&quot;../db&quot;))) and it printed the correct directory path. ???

The reason I wanted to use it was that I am a sole proprietor for a university in IL, while I'm in North Carolina. So we tranfer files back and forth and it would be easier to have it auto find the db as it is relative to the web site, not our server's file structures.

But thank you for your help that you've givin thus far! Much Appreciated! -Ovatvvon :-Q
 
Does the connection string work if you provide the physical path instead of using server.mappath ??

Remember, I don't use server.mappath OR DSNless connection strings in my application, so I may be running out of advice here.

TW
 
For testing purposes, issue..


Response.Write connString


See if you see any problems in the entire connection string.

TW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top