[RESOLVED] Problem while reading .dbf file from server
I don’t know where to put this Query.
I am trying to open .dbf file from the server for which I have written below code.
Now, the problem is connection string accepts only physical path from the client machine where as I want it to pick file from the server.
Please guide me how to resolve this problem.
System.Data.Odbc.OdbcConnection oConn = new System.Data.Odbc.OdbcConnection();
oConn.ConnectionString = @"Driver={Microsoft dBase Driver (*.dbf)};SourceType=DBF;SourceDB= http://localhost:1308/CNCScheduling/...;Exclusive=No; Collate=Machine;NULL=NO;DELETED=NO;BACKGROUNDFETCH=NO;";
oConn.Open();
System.Data.Odbc.OdbcCommand oCmd = oConn.CreateCommand();
string sPathApp = Request.ApplicationPath.ToString() + "/";
string sPathFull = Request.Url.OriginalString.ToString();
int iPathFullLen = sPathFull.ToUpper().IndexOf(sPathApp.ToUpper());
string sPathPrefix = sPathFull.Substring(0, iPathFullLen) + sPathApp;
string sRPTFile = "XABCL.DBF";
string sCrvPage = "D:\\databases\\" + sRPTFile;
oCmd.CommandText = @"SELECT * FROM " + sCrvPage ;
DataTable dt = new DataTable();
dt.Load(oCmd.ExecuteReader());
help needed urgently.
Regards,
PPCC:mad:
Re: Problem while reading .dbf file from server
Hey,
Have you checked connectionstrings.com?
They seem to have a second connection string that can be used for a database on a remote drive:
http://www.connectionstrings.com/dbf-foxpro#p91
Where exactly is this database located, which respect to your application? And why are you trying to access it using a web address?
Gary
Re: Problem while reading .dbf file from server
Quote:
Originally Posted by
gep13
Hey,
Have you checked connectionstrings.com?
They seem to have a second connection string that can be used for a database on a remote drive:
http://www.connectionstrings.com/dbf-foxpro#p91
Where exactly is this database located, which respect to your application? And why are you trying to access it using a web address?
Gary
hey,
I am uploading dbf file onto the server and trying to open that dbf file using web link
I have tried 2 connection strings to open dbf file.
1. oConn.ConnectionString = @"Driver={Microsoft dBase Driver (*.dbf)};datasource=\UploadFolder\XABCL.DBF;";
2. oConn.ConnectionString = @"Driver={Microsoft dBase Driver (*.dbf)};datasource=http://localhost:1336/Project/UploadFolder/ XABCL.DBF";
oCmd.CommandText = @"SELECT * FROM XABCL.DBF”.
pl help me how to open dbf file.
Re: Problem while reading .dbf file from server
Hey,
I take it you are getting an exception, so what is it?
Is the Database in your project AppData folder? It's likely that you are going to need to give it the full path to the database, not a relative one, i.e. c:\path to folder\xabcl.dbf.
Given that you are creating the connectionstring in code, you should be able to do the following:
Code:
oConn.ConnectionString = @"Driver={Microsoft dBase Driver (*.dbf)};datasource=" + Server.MapPath("UploadFolder\XABCL.DBF") + ";";
Bear in mind, the above was written outwith the IDE, and may contain errors. But the premise is the use of Server.MapPath to go from a relative path, to the absolute path on the file system:
http://msdn.microsoft.com/en-us/library/ms524632.aspx
Hope that helps!
Gary
Re: Problem while reading .dbf file from server
finally i have changed my design and picking file from client side.
Re: [RESOLVED] Problem while reading .dbf file from server
Hey,
Can you perhaps provide some details as to what exactly you did?
Did the above not work for you?
Gary
Re: [RESOLVED] Problem while reading .dbf file from server
Quote:
Originally Posted by
gep13
Hey,
Can you perhaps provide some details as to what exactly you did?
Did the above not work for you?
Gary
Nope:blush::confused:, after mapping with Server.mappath also it is showing dbf file not found.wel due to time constraints i have to changed my design now thanks Gary
Re: [RESOLVED] Problem while reading .dbf file from server
Hey,
Ok, that is quite strange.
I am glad that you found a solution, maybe something to look at again in the future.
Gary