472,977 Members | 1,878 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,977 software developers and data experts.

can't see this odbc datasource on the network from a web service

cj2
This code works:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data.Odbc;

namespace CWebService1
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// To allow this Web Service to be called from script, using
ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{

[WebMethod()]
public string CashOnly(string act)
{
DataSet ds = new DataSet();
OdbcConnection myOdbcConnection = new
OdbcConnection("Driver={Microsoft Visual FoxPro Driver};"
+ "SourceType=DBF;"
+ "SourceDB=c:;"
+ "Exclusive=No;"
+ "Collate=Machine;"
+ "NULL=NO;"
+ "DELETED=NO;"
+ "BACKGROUNDFETCH=NO");

OdbcCommand myOdbcCommand = new OdbcCommand("select flag
from d:\\act_frau.DBF where act = '" + act.Trim() + "'", myOdbcConnection);
myOdbcConnection.Open();
string results = myOdbcCommand.ExecuteScalar().ToString();
myOdbcConnection.Close();

return results;

}
}
}
But with the actual production file on the network it doesn't:

OdbcCommand myOdbcCommand = new OdbcCommand("select flag
from \\\\fileserver\\i\\probill\\act_frau.DBF where act = '" +
act.Trim() + "'", myOdbcConnection);

It gives me:

System.Data.Odbc.OdbcException: ERROR [42S02] [Microsoft][ODBC Visual
FoxPro Driver]File 'act_frau.dbf' does not exist.

The file does exist. FYI, i is a directory not a drive letter.

I've also tried this web service in VB and it works:

Dim myOdbcCommand As New OdbcCommand("select flag from
\\fileserver\i\probill\act_frau.dbf where act = '" + act.Trim + "'",
myOdbcConnection)

What am I doing wrong?
Jul 2 '08 #1
5 1920
Hi Cj,

From your description, you're trying to connect a VFP database in an
ASP.NET webservice, you used the ODBC driver. However, you found that the
code didn't work in webservice(from a network place) while worked for a
database file on local disk, correct?

I've also discussed this with some other database engineer. They suggest
you check the following things:

1.Make sure there hasn't any other program or person that has opened the
vfp database before your code accesss it. That'll possibly cause the
database not found error.

2. In the code, the only difference is the string escaping for the back
slash. I suggest you try using the following style code in C3 to see
whether it works:

OdbcCommand myOdbcCommand = new OdbcCommand(@"select flag from
\\fileserver\i\probill\act_frau.DBF where act = '" + act.Trim() + "'",
myOdbcConnection);

Btw, regarding on the network place, have you tried performing some other
simple remote resource accessing , such as try accessing a file via
System.IO API on that server to see whether you'll get similar error? If
so, that may indicate some network resource accessing issue.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>Date: Wed, 02 Jul 2008 10:42:06 -0400
From: cj2 <cj*@nospam.nospam>
User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
MIME-Version: 1.0
Subject: can't see this odbc datasource on the network from a web service
>
This code works:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data.Odbc;

namespace CWebService1
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// To allow this Web Service to be called from script, using
ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{

[WebMethod()]
public string CashOnly(string act)
{
DataSet ds = new DataSet();
OdbcConnection myOdbcConnection = new
OdbcConnection("Driver={Microsoft Visual FoxPro Driver};"
+ "SourceType=DBF;"
+ "SourceDB=c:;"
+ "Exclusive=No;"
+ "Collate=Machine;"
+ "NULL=NO;"
+ "DELETED=NO;"
+ "BACKGROUNDFETCH=NO");

OdbcCommand myOdbcCommand = new OdbcCommand("select flag
from d:\\act_frau.DBF where act = '" + act.Trim() + "'", myOdbcConnection);
myOdbcConnection.Open();
string results = myOdbcCommand.ExecuteScalar().ToString();
myOdbcConnection.Close();

return results;

}
}
}
But with the actual production file on the network it doesn't:

OdbcCommand myOdbcCommand = new OdbcCommand("select flag
from \\\\fileserver\\i\\probill\\act_frau.DBF where act = '" +
act.Trim() + "'", myOdbcConnection);

It gives me:

System.Data.Odbc.OdbcException: ERROR [42S02] [Microsoft][ODBC Visual
FoxPro Driver]File 'act_frau.dbf' does not exist.

The file does exist. FYI, i is a directory not a drive letter.

I've also tried this web service in VB and it works:

Dim myOdbcCommand As New OdbcCommand("select flag from
\\fileserver\i\probill\act_frau.dbf where act = '" + act.Trim + "'",
myOdbcConnection)

What am I doing wrong?
Jul 3 '08 #2
cj2
I had a small breakthrough today. I found when I run the web service
from within Visual Studio by doing debug start it works! Unfortunately
when I publish it to local host it doesn't. Why do you think that would
be the case?

OdbcCommand myOdbcCommand = new OdbcCommand("select flag from
\\\\fileserver\\i\\probill\\act_frau.DBF where act = '" + act.Trim() +
"'", myOdbcConnection);
Steven Cheng [MSFT] wrote:
Hi Cj,

From your description, you're trying to connect a VFP database in an
ASP.NET webservice, you used the ODBC driver. However, you found that the
code didn't work in webservice(from a network place) while worked for a
database file on local disk, correct?

I've also discussed this with some other database engineer. They suggest
you check the following things:

1.Make sure there hasn't any other program or person that has opened the
vfp database before your code accesss it. That'll possibly cause the
database not found error.

2. In the code, the only difference is the string escaping for the back
slash. I suggest you try using the following style code in C3 to see
whether it works:

OdbcCommand myOdbcCommand = new OdbcCommand(@"select flag from
\\fileserver\i\probill\act_frau.DBF where act = '" + act.Trim() + "'",
myOdbcConnection);

Btw, regarding on the network place, have you tried performing some other
simple remote resource accessing , such as try accessing a file via
System.IO API on that server to see whether you'll get similar error? If
so, that may indicate some network resource accessing issue.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>Date: Wed, 02 Jul 2008 10:42:06 -0400
From: cj2 <cj*@nospam.nospam>
User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
MIME-Version: 1.0
Subject: can't see this odbc datasource on the network from a web service
>This code works:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data.Odbc;

namespace CWebService1
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// To allow this Web Service to be called from script, using
ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{

[WebMethod()]
public string CashOnly(string act)
{
DataSet ds = new DataSet();
OdbcConnection myOdbcConnection = new
OdbcConnection("Driver={Microsoft Visual FoxPro Driver};"
+ "SourceType=DBF;"
+ "SourceDB=c:;"
+ "Exclusive=No;"
+ "Collate=Machine;"
+ "NULL=NO;"
+ "DELETED=NO;"
+ "BACKGROUNDFETCH=NO");

OdbcCommand myOdbcCommand = new OdbcCommand("select flag
from d:\\act_frau.DBF where act = '" + act.Trim() + "'", myOdbcConnection);
myOdbcConnection.Open();
string results = myOdbcCommand.ExecuteScalar().ToString();
myOdbcConnection.Close();

return results;

}
}
}
But with the actual production file on the network it doesn't:

OdbcCommand myOdbcCommand = new OdbcCommand("select flag
from \\\\fileserver\\i\\probill\\act_frau.DBF where act = '" +
act.Trim() + "'", myOdbcConnection);

It gives me:

System.Data.Odbc.OdbcException: ERROR [42S02] [Microsoft][ODBC Visual
FoxPro Driver]File 'act_frau.dbf' does not exist.

The file does exist. FYI, i is a directory not a drive letter.

I've also tried this web service in VB and it works:

Dim myOdbcCommand As New OdbcCommand("select flag from
\\fileserver\i\probill\act_frau.dbf where act = '" + act.Trim + "'",
myOdbcConnection)

What am I doing wrong?
Jul 3 '08 #3
Thanks for your reply Cj,

I think the further information you mentioned is quite important. That make
me think that the issue is probably due to the application's execution
context(user account).

For ASP.NET web application/webservice which run via Visual Studio built-in
server, since the built-in server is winform application, your web app code
is actually running under your current logon user account(under which the
visual studio also runs).

However, if you deployed it into IIS,(suppose you're using IIS6 on win2k3
or iis7 on vista), by default the web app is running under the IIS worker
process account( e.g the Network Service for IIS6 app pool).

Therefore, I suggest you first focus on this. For example, you can try
changing your IIS worker process account(app pool account) to an
interactive user account to see whether it works. Or you can
programmtically impersonate as a certain interactive user account at the
code you call the ODBC database.

For impersonate, you can refer to the following articles:

#How To: Use Impersonation and Delegation in ASP.NET 2.0
http://msdn.microsoft.com/en-us/library/ms998351.aspx

http://support.microsoft.com/kb/306158

If there is anything unclear or any other findings, please feel free to let
me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Date: Thu, 03 Jul 2008 14:41:11 -0400
MIME-Version: 1.0
Subject: Re: can't see this odbc datasource on the network from a web
service
>
I had a small breakthrough today. I found when I run the web service
from within Visual Studio by doing debug start it works! Unfortunately
when I publish it to local host it doesn't. Why do you think that would
be the case?

OdbcCommand myOdbcCommand = new OdbcCommand("select flag from
\\\\fileserver\\i\\probill\\act_frau.DBF where act = '" + act.Trim() +
"'", myOdbcConnection);
>>>The file does exist. FYI, i is a directory not a drive letter.

I've also tried this web service in VB and it works:

Dim myOdbcCommand As New OdbcCommand("select flag from
\\fileserver\i\probill\act_frau.dbf where act = '" + act.Trim + "'",
myOdbcConnection)

What am I doing wrong?
Jul 4 '08 #4
cj2
That's it. I don't know why I missed that. I had impersonation set up
in the Web.config files of my VB ASP.net programs but totally forgot it
when creating this C# program.

Thanks,
CJ

Steven Cheng [MSFT] wrote:
Thanks for your reply Cj,

I think the further information you mentioned is quite important. That make
me think that the issue is probably due to the application's execution
context(user account).

For ASP.NET web application/webservice which run via Visual Studio built-in
server, since the built-in server is winform application, your web app code
is actually running under your current logon user account(under which the
visual studio also runs).

However, if you deployed it into IIS,(suppose you're using IIS6 on win2k3
or iis7 on vista), by default the web app is running under the IIS worker
process account( e.g the Network Service for IIS6 app pool).

Therefore, I suggest you first focus on this. For example, you can try
changing your IIS worker process account(app pool account) to an
interactive user account to see whether it works. Or you can
programmtically impersonate as a certain interactive user account at the
code you call the ODBC database.

For impersonate, you can refer to the following articles:

#How To: Use Impersonation and Delegation in ASP.NET 2.0
http://msdn.microsoft.com/en-us/library/ms998351.aspx

http://support.microsoft.com/kb/306158

If there is anything unclear or any other findings, please feel free to let
me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Date: Thu, 03 Jul 2008 14:41:11 -0400
MIME-Version: 1.0
Subject: Re: can't see this odbc datasource on the network from a web
service
>I had a small breakthrough today. I found when I run the web service
from within Visual Studio by doing debug start it works! Unfortunately
when I publish it to local host it doesn't. Why do you think that would
be the case?

OdbcCommand myOdbcCommand = new OdbcCommand("select flag from
\\\\fileserver\\i\\probill\\act_frau.DBF where act = '" + act.Trim() +
"'", myOdbcConnection);
>>>>The file does exist. FYI, i is a directory not a drive letter.
I've also tried this web service in VB and it works:

Dim myOdbcCommand As New OdbcCommand("select flag from
\\fileserver\i\probill\act_frau.dbf where act = '" + act.Trim + "'",
myOdbcConnection)

What am I doing wrong?
Jul 7 '08 #5
Thanks for your followup CJ,

I'm glad that you've figured out the problem.

Have a good day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Date: Mon, 07 Jul 2008 10:58:05 -0400
From: cj2 <cj*@nospam.nospam>
User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
MIME-Version: 1.0
Subject: Re: can't see this odbc datasource on the network from a web
service
>
That's it. I don't know why I missed that. I had impersonation set up
in the Web.config files of my VB ASP.net programs but totally forgot it
when creating this C# program.

Thanks,
CJ

Steven Cheng [MSFT] wrote:
>Thanks for your reply Cj,

I think the further information you mentioned is quite important. That
make
>me think that the issue is probably due to the application's execution
context(user account).

For ASP.NET web application/webservice which run via Visual Studio
built-in
>server, since the built-in server is winform application, your web app
code
>is actually running under your current logon user account(under which
the
>visual studio also runs).

However, if you deployed it into IIS,(suppose you're using IIS6 on
win2k3
>or iis7 on vista), by default the web app is running under the IIS
worker
>process account( e.g the Network Service for IIS6 app pool).

Therefore, I suggest you first focus on this. For example, you can try
changing your IIS worker process account(app pool account) to an
interactive user account to see whether it works. Or you can
programmtically impersonate as a certain interactive user account at the
code you call the ODBC database.

For impersonate, you can refer to the following articles:

#How To: Use Impersonation and Delegation in ASP.NET 2.0
http://msdn.microsoft.com/en-us/library/ms998351.aspx

http://support.microsoft.com/kb/306158

If there is anything unclear or any other findings, please feel free to
let
>me know.

Sincerely,

Steven Cheng

Jul 8 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jamie Burns | last post by:
I have written a Windows Service to access an Oracle database. A dialog box appears, prompting for user logon if the database is not accessable due to network problems I just want the connection...
1
by: Lyle Fairfield | last post by:
I created a new MS-SQL Database, "TestODBC". I made Table1 and StoredProcedure1. I made an ODBC DSN for that MS-SQL Database. I created a new AccessXP mdb, "TestODBC". I linked to the...
5
by: Jerry Hull | last post by:
I'm working with a database developed by an untrained person over several years - and on a network that has recently been upgraded with a new server installed and MS office upgraded from 2K (I...
0
by: astro | last post by:
I am getting connection errors to an pervasive ODBC datasource ('Timerline' is the packaged product I am linking to). It works one week and the next week - all the links are invalid. I've checked...
1
by: Mike Grishaber | last post by:
Hello All, Does anyone know how to programatically create an ODBC datasource in C#? I want to access some comma separated files using ODBC, and I don't want to go into the configuration...
1
by: MethMath | last post by:
I have problems with a webservice receiving data in turn updating an Odbc-linked Access database on the same computer. The Odbc engine gives me an OdbcExceptionError: Message: Operation must...
2
by: Mike | last post by:
Can a vb program running as a serice not use network paths to do file/io? I can't seem to get my program to work with network paths and files. When I use local disk it works fine. When I run it...
1
by: marcnz | last post by:
I have been charged of creating a coldfusion web site for our company. Our database has a ms sql 2005 backend and ms access frontend. Almost all tables are linked tables with the SQL database,...
8
lifeisgreat20009
by: lifeisgreat20009 | last post by:
What might be the possible cause ? I have created a website using struts framework, jsp In my transaction page the money is not getting transferred.. When I hit the submit button in my...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.