469,903 Members | 1,909 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

Invalid cast on SQL to other server

Making the following call to a local MSAccess database works fine:

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim intRows As Integer
Dim strSQL As String
Dim ds As New DataSet
' Create connection
Dim cn As New OleDbConnection
With cn
.connectionstring = "provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\PDB\Development\Database\PDB.mdb"
End With
' Open connection
cn.Open()
' -----------------------------------------------------------
' Get System Name
' -----------------------------------------------------------
' Create command
Dim cmd1 As New OleDbCommand
With cmd1
.Connection = cn
.CommandText = "SELECT System FROM Reference"
End With
' Execute the SQL
Dim strSystemName As Integer = cmd1.ExecuteScalar
However, changing the connectionstring to

.ConnectionString = "Provider=MS Remote;" & _
"Remote Server=http://scfmzcp1;" & _
"Remote Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=W:\PDB\Development\PDB.mdb;" & _
"Connection Timeout=30"

causes a "Specified cast is not valid" message on the ExecuteScalar line.

Thanks for your help

John
Nov 20 '05 #1
21 1676
In article <40********@news.hcs.net>, john@nowhere says...
Making the following call to a local MSAccess database works fine:

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim intRows As Integer
Dim strSQL As String
Dim ds As New DataSet
' Create connection
Dim cn As New OleDbConnection
With cn
.connectionstring = "provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\PDB\Development\Database\PDB.mdb"
End With
' Open connection
cn.Open()
' -----------------------------------------------------------
' Get System Name
' -----------------------------------------------------------
' Create command
Dim cmd1 As New OleDbCommand
With cmd1
.Connection = cn
.CommandText = "SELECT System FROM Reference"
End With
' Execute the SQL
Dim strSystemName As Integer = cmd1.ExecuteScalar
However, changing the connectionstring to

.ConnectionString = "Provider=MS Remote;" & _
"Remote Server=http://scfmzcp1;" & _
"Remote Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=W:\PDB\Development\PDB.mdb;" & _
"Connection Timeout=30"

causes a "Specified cast is not valid" message on the ExecuteScalar line.


To debug, change the line to:

dim temp as Object = cmd1.ExecuteScalar

And see what "temp" is in the debug window. It's obviously something
that can't be cast to an Integer.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 20 '05 #2
Hi John

In addition to what Patrick suggested i would use a
SqlDataReader to hold the result of your select command
since its possible that it is returning several rows.

Kind Regards
Jorge
-----Original Message-----
Making the following call to a local MSAccess database works fine:
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) Dim intRows As Integer
Dim strSQL As String
Dim ds As New DataSet
' Create connection
Dim cn As New OleDbConnection
With cn
.connectionstring = "provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\PDB\Development\Database\PDB.mdb" End With
' Open connection
cn.Open()
' ----------------------------------------------- ------------ ' Get System Name
' ----------------------------------------------- ------------ ' Create command
Dim cmd1 As New OleDbCommand
With cmd1
.Connection = cn
.CommandText = "SELECT System FROM Reference"
End With
' Execute the SQL
Dim strSystemName As Integer = cmd1.ExecuteScalar
However, changing the connectionstring to

.ConnectionString = "Provider=MS Remote;" & _ "Remote Server=http://scfmzcp1;" & _
"Remote Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=W:\PDB\Development\PDB.mdb;" & _ "Connection Timeout=30"

causes a "Specified cast is not valid" message on the ExecuteScalar line.
Thanks for your help

John
.

Nov 20 '05 #3
Is SP return any value?
Maybe you have CAST in sp???

Gerasha

"John Howard" <john@nowhere> wrote in message news:40******@news.hcs.net...
Dim dr As OleDbDataReader = cmd1.ExecuteReader

Same error

"John Howard" <john@nowhere> wrote in message

news:40******@news.hcs.net...
This table has only one row.

"Jorge" <an*******@discussions.microsoft.com> wrote in message
news:19*****************************@phx.gbl...
Hi John

In addition to what Patrick suggested i would use a
SqlDataReader to hold the result of your select command
since its possible that it is returning several rows.

Kind Regards
Jorge
>-----Original Message-----
>Making the following call to a local MSAccess database
works fine:
>
> Sub Session_Start(ByVal sender As Object, ByVal e As
EventArgs)
> Dim intRows As Integer
> Dim strSQL As String
> Dim ds As New DataSet
> ' Create connection
> Dim cn As New OleDbConnection
> With cn
> .connectionstring
= "provider=Microsoft.Jet.OLEDB.4.0;" & _
> "Data
Source=C:\PDB\Development\Database\PDB.mdb"
> End With
> ' Open connection
> cn.Open()
> ' -----------------------------------------------
------------
> ' Get System Name
> ' -----------------------------------------------
------------
> ' Create command
> Dim cmd1 As New OleDbCommand
> With cmd1
> .Connection = cn
> .CommandText = "SELECT System FROM Reference"
> End With
> ' Execute the SQL
> Dim strSystemName As Integer = cmd1.ExecuteScalar
>
>
>However, changing the connectionstring to
>
> .ConnectionString = "Provider=MS Remote;" &
_
> "Remote Server=http://scfmzcp1;" & _
> "Remote
Provider=Microsoft.Jet.OLEDB.4.0;" & _
> "Data
Source=W:\PDB\Development\PDB.mdb;" & _
> "Connection Timeout=30"
>
>causes a "Specified cast is not valid" message on the
ExecuteScalar line.
>
>Thanks for your help
>
>John
>
>
>.
>



Nov 20 '05 #4
In article <40********@news.hcs.net>, john@nowhere says...
Dim temp As Object = cmd1.ExecuteScalar

Amazing - this gives the same error.


Very odd... Does the Exception that is thrown contain anything in the
"InnerException" property? There's got to be a stack trace somewhere
showing exactly what is throwing the invalid cast exception.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 20 '05 #5
I don't understand

"Herman Kheyfets" <we***@gerasha.com> wrote in message
news:uC**************@TK2MSFTNGP11.phx.gbl...
Is SP return any value?
Maybe you have CAST in sp???

Gerasha

"John Howard" <john@nowhere> wrote in message

news:40******@news.hcs.net...
Dim dr As OleDbDataReader = cmd1.ExecuteReader

Same error

"John Howard" <john@nowhere> wrote in message

news:40******@news.hcs.net...
This table has only one row.

"Jorge" <an*******@discussions.microsoft.com> wrote in message
news:19*****************************@phx.gbl...
> Hi John
>
> In addition to what Patrick suggested i would use a
> SqlDataReader to hold the result of your select command
> since its possible that it is returning several rows.
>
> Kind Regards
> Jorge
> >-----Original Message-----
> >Making the following call to a local MSAccess database
> works fine:
> >
> > Sub Session_Start(ByVal sender As Object, ByVal e As
> EventArgs)
> > Dim intRows As Integer
> > Dim strSQL As String
> > Dim ds As New DataSet
> > ' Create connection
> > Dim cn As New OleDbConnection
> > With cn
> > .connectionstring
> = "provider=Microsoft.Jet.OLEDB.4.0;" & _
> > "Data
> Source=C:\PDB\Development\Database\PDB.mdb"
> > End With
> > ' Open connection
> > cn.Open()
> > ' -----------------------------------------------
> ------------
> > ' Get System Name
> > ' -----------------------------------------------
> ------------
> > ' Create command
> > Dim cmd1 As New OleDbCommand
> > With cmd1
> > .Connection = cn
> > .CommandText = "SELECT System FROM Reference"
> > End With
> > ' Execute the SQL
> > Dim strSystemName As Integer = cmd1.ExecuteScalar
> >
> >
> >However, changing the connectionstring to
> >
> > .ConnectionString = "Provider=MS Remote;" &
> _
> > "Remote Server=http://scfmzcp1;" & _
> > "Remote
> Provider=Microsoft.Jet.OLEDB.4.0;" & _
> > "Data
> Source=W:\PDB\Development\PDB.mdb;" & _
> > "Connection Timeout=30"
> >
> >causes a "Specified cast is not valid" message on the
> ExecuteScalar line.
> >
> >Thanks for your help
> >
> >John
> >
> >
> >.
> >



Nov 20 '05 #6
Here is the result. I can't make any sense of it:

Line 71: ' Execute the SQL
Line 72: 'Dim dr As OleDbDataReader = cmd1.ExecuteReader
Line 73: Dim temp As Object = cmd1.ExecuteScalar
Line 74: Dim strSystemName As Integer
Line 75: 'Dim strSystemName As Integer = cmd1.ExecuteScalar
Source File: C:\Inetpub\wwwroot\WebPDB2\Global.asax.vb Line: 73

Stack Trace:

[InvalidCastException: Specified cast is not valid.]
System.Data.OleDb.OleDbException..ctor(IErrorInfo errorInfo, Int32
errorCode, Exception inner)
System.Data.OleDb.OleDbConnection.ProcessResults(I nt32 hResult,
OleDbConnection connection, Object src)
System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32 hr)

System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult)
System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior,
Object& executeResult)
System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
behavior, String method)
System.Data.OleDb.OleDbCommand.ExecuteScalar()
WebPDB2.Global.Session_Start(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\WebPDB2\Global.asax.vb:73
System.Web.SessionState.SessionStateModule.RaiseOn Start(EventArgs e)
System.Web.SessionState.SessionStateModule.OnStart (EventArgs e)
System.Web.SessionState.SessionStateModule.Complet eAcquireState()
System.Web.SessionState.SessionStateModule.BeginAc quireState(Object
source, EventArgs e, AsyncCallback cb, Object extraData)

System.Web.AsyncEventExecutionStep.System.Web.Http Application+IExecutionStep
..Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +173


"Patrick Steele [MVP]" <pa*****@mvps.org> wrote in message
news:MP************************@msnews.microsoft.c om...
In article <40********@news.hcs.net>, john@nowhere says...
Dim temp As Object = cmd1.ExecuteScalar

Amazing - this gives the same error.


Very odd... Does the Exception that is thrown contain anything in the
"InnerException" property? There's got to be a stack trace somewhere
showing exactly what is throwing the invalid cast exception.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele

Nov 20 '05 #7
* "John Howard" <john@nowhere> scripsit:
Making the following call to a local MSAccess database works fine:

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim intRows As Integer
Dim strSQL As String
Dim ds As New DataSet
' Create connection
Dim cn As New OleDbConnection
With cn
.connectionstring = "provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\PDB\Development\Database\PDB.mdb"
End With
' Open connection
cn.Open()
' -----------------------------------------------------------
' Get System Name
' -----------------------------------------------------------
' Create command
Dim cmd1 As New OleDbCommand
With cmd1
.Connection = cn
.CommandText = "SELECT System FROM Reference"
End With
' Execute the SQL
Dim strSystemName As Integer = cmd1.ExecuteScalar
However, changing the connectionstring to

.ConnectionString = "Provider=MS Remote;" & _
"Remote Server=http://scfmzcp1;" & _
"Remote Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=W:\PDB\Development\PDB.mdb;" & _
"Connection Timeout=30"

causes a "Specified cast is not valid" message on the ExecuteScalar line.


.... I suggest to ask this question in a more appropriate group:

<URL:news://news.microsoft.com/microsoft.public.dotnet.framework.adonet>

Web interface:

<URL:http://msdn.microsoft.com/newsgroups/?dg=microsoft.public.dotnet.framework.adonet>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #8
Hi John,

Is the field description of both databases equal

You can of course just try this
Dim strSystemName As Integer = Cint(cmd1.ExecuteScalar)

Just a thought,

Cor
Nov 20 '05 #9
Same error again.

Specified cast is not valid.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not
valid.

Source Error:
Line 70: End With
Line 71: ' Execute the SQL
Line 72: Dim strSystemName As Integer =
CInt(cmd1.ExecuteScalar)
Line 73: 'Dim dr As OleDbDataReader = cmd1.ExecuteReader
Line 74: 'Dim temp As Object = cmd1.ExecuteScalar
Source File: C:\Inetpub\wwwroot\WebPDB2\Global.asax.vb Line: 72

Stack Trace:
[InvalidCastException: Specified cast is not valid.]
System.Data.OleDb.OleDbException..ctor(IErrorInfo errorInfo, Int32
errorCode, Exception inner)
System.Data.OleDb.OleDbConnection.ProcessResults(I nt32 hResult,
OleDbConnection connection, Object src)

System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32
hr)

System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object&
executeResult)
System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior
behavior, Object& executeResult)

System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
behavior, String method)
System.Data.OleDb.OleDbCommand.ExecuteScalar()
WebPDB2.Global.Session_Start(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\WebPDB2\Global.asax.vb:72
System.Web.SessionState.SessionStateModule.RaiseOn Start(EventArgs
e)
System.Web.SessionState.SessionStateModule.OnStart (EventArgs e)
System.Web.SessionState.SessionStateModule.Complet eAcquireState()
System.Web.SessionState.SessionStateModule.BeginAc quireState(Object
source, EventArgs e, AsyncCallback cb, Object extraData)

System.Web.AsyncEventExecutionStep.System.Web.Http Application+IExecutionStep.Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step,
Boolean& completedSynchronously) +173


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573;
ASP.NET Version:1.1.4322.573

On Tue, 8 Jun 2004 20:34:58 +0200, "Cor Ligthert"
<no**********@planet.nl> wrote:
Hi John,

Is the field description of both databases equal

You can of course just try this
Dim strSystemName As Integer = Cint(cmd1.ExecuteScalar)

Just a thought,

Cor


Nov 20 '05 #10
Hi John,
Same error again.

Line 74: 'Dim temp As Object = cmd1.ExecuteScalar
Dim strSystemName As Integer = Cint(cmd1.ExecuteScalar)

How can that be the same error?

Cor
Nov 20 '05 #11
Cor:

I wish I knew. I'm beginning to think that this error message may be
a "Red Herring", leading us astray. I commented out this code and
allowed processing to drop through to the next SQL - a Fill for a data
adapter against anogther table. And guess what? Same error message.

This is leading me to believe that the problem may be completely
unrelated to casting, but more related to a db connection.

What do you thinK?

On Tue, 8 Jun 2004 21:12:12 +0200, "Cor Ligthert"
<no**********@planet.nl> wrote:
Hi John,
Same error again.

Line 74: 'Dim temp As Object = cmd1.ExecuteScalar
>Dim strSystemName As Integer = Cint(cmd1.ExecuteScalar)
>

How can that be the same error?

Cor


Nov 20 '05 #12
Hi John,

That was what I was thinking, maybe just make another simple execute command
or even create a dataadapter or whatever than you know it.

dim ds as new dataset
dim da as new OleDbdataadapter(cmd1)
da.fill(da)

should work in my opinion.

You can try.

Cor
Nov 20 '05 #13
This results in:

Specified cast is not valid.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not
valid.

Source Error:
Line 79: Dim da As New OleDbDataAdapter(cmd1)
Line 80: 'ds9.Fill(da)
Line 81: da.Fill(ds)
Line 82:
Line 83: Dim strSystemName As Integer
Source File: C:\Inetpub\wwwroot\WebPDB2\Global.asax.vb Line: 81

Stack Trace:
[InvalidCastException: Specified cast is not valid.]
System.Data.OleDb.OleDbException..ctor(IErrorInfo errorInfo, Int32
errorCode, Exception inner)
System.Data.OleDb.OleDbConnection.ProcessResults(I nt32 hResult,
OleDbConnection connection, Object src)

System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32
hr)

System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object&
executeResult)
System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior
behavior, Object& executeResult)

System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
behavior, String method)
System.Data.OleDb.OleDbCommand.ExecuteReader(Comma ndBehavior
behavior)

System.Data.OleDb.OleDbCommand.System.Data.IDbComm and.ExecuteReader(CommandBehavior
behavior)
System.Data.Common.DbDataAdapter.FillFromCommand(O bject data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
WebPDB2.Global.Session_Start(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\WebPDB2\Global.asax.vb:81
System.Web.SessionState.SessionStateModule.RaiseOn Start(EventArgs
e)
System.Web.SessionState.SessionStateModule.OnStart (EventArgs e)
System.Web.SessionState.SessionStateModule.Complet eAcquireState()
System.Web.SessionState.SessionStateModule.BeginAc quireState(Object
source, EventArgs e, AsyncCallback cb, Object extraData)

System.Web.AsyncEventExecutionStep.System.Web.Http Application+IExecutionStep.Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step,
Boolean& completedSynchronously) +173


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573;
ASP.NET Version:1.1.4322.573

On Tue, 8 Jun 2004 21:57:12 +0200, "Cor Ligthert"
<no**********@planet.nl> wrote:
Hi John,

That was what I was thinking, maybe just make another simple execute command
or even create a dataadapter or whatever than you know it.

dim ds as new dataset
dim da as new OleDbdataadapter(cmd1)
da.fill(da)

should work in my opinion.

You can try.

Cor


Nov 20 '05 #14
Hi John,

Did you try it already with a simple connections string to that virtual W
drive?

I never saw this one, where did you get it?

Cor
Nov 20 '05 #15
Cor:

I assume you are referring to the connectionstring:

..ConnectionString = "Provider=MS Remote;" & _
"Remote Server=http://scfmzcp1;" & _
"Remote Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=W:\PDB\Development\PDB.mdb;" & _
"Connection Timeout=30"

which I got from a web site after having problems connecting to a
remote (LAN) drive after just changing the Data Source, as follows:

.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;Data
Source=W:\PDB\Development\PDB.mdb"
And yes, I did try that with the following result:

'W:\PDB\Development\PDB.mdb' is not a valid path. Make sure that the
path name is spelled correctly and that you are connected to the
server on which the file resides.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException:
'W:\PDB\Development\PDB.mdb' is not a valid path. Make sure that the
path name is spelled correctly and that you are connected to the
server on which the file resides.

Source Error:
Line 55: ' Open connection
Line 56: 'Try
Line 57: cn.Open()
Line 58: 'Catch
Line 59: ' Response.Write("Connection error: " &
Err.Description)
Source File: C:\Inetpub\wwwroot\WebPDB2\Global.asax.vb Line: 57

Stack Trace:
[OleDbException (0x80004005): 'W:\PDB\Development\PDB.mdb' is not a
valid path. Make sure that the path name is spelled correctly and
that you are connected to the server on which the file resides.]
System.Data.OleDb.OleDbConnection.ProcessResults(I nt32 hr)
System.Data.OleDb.OleDbConnection.InitializeProvid er()
System.Data.OleDb.OleDbConnection.Open()
WebPDB2.Global.Session_Start(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\WebPDB2\Global.asax.vb:57
System.Web.SessionState.SessionStateModule.RaiseOn Start(EventArgs
e)
System.Web.SessionState.SessionStateModule.OnStart (EventArgs e)
System.Web.SessionState.SessionStateModule.Complet eAcquireState()
System.Web.SessionState.SessionStateModule.BeginAc quireState(Object
source, EventArgs e, AsyncCallback cb, Object extraData)

System.Web.AsyncEventExecutionStep.System.Web.Http Application+IExecutionStep.Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step,
Boolean& completedSynchronously) +173


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573;
ASP.NET Version:1.1.4322.573

On Wed, 9 Jun 2004 13:01:45 +0200, "Cor Ligthert"
<no**********@planet.nl> wrote:
Hi John,

Did you try it already with a simple connections string to that virtual W
drive?

I never saw this one, where did you get it?

Cor


Nov 20 '05 #16
Hi John,

Did you see this page?
http://www.able-consulting.com/ADO_Conn.htm

And the link after obsolete almost at the bottom
Maybe that can help you?

Cor
Nov 20 '05 #17
Using the connection string:

..ConnectionString = "Provider=MS Remote;" & _

"Remote Server=http://scfmzcp1;" & _

"Remote Provider=Microsoft.Jet.OLEDB.4.0;" & _

"Data Source=C:\PDB\Development\PDB.mdb, admin, "

I get the imvalid cast message.

Do I have the Remote Server and Data Source parameters correct?

John

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi John,

Did you see this page?
http://www.able-consulting.com/ADO_Conn.htm

And the link after obsolete almost at the bottom
Maybe that can help you?

Cor

Nov 20 '05 #18
I wasn't able to see anything at this URL that seemed to be the answer.

However, I may have another clue. In order to crystalize the problem, I
created the following program:

Imports System.Data.OleDb

Public Class WebForm1

Inherits System.Web.UI.Page

.......

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim intRows As Integer

Dim strSQL As String

Dim ds As New DataSet

Dim cn As New OleDbConnection

cn.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;Data
Source=W:\PDB\Development\PDB.mdb"

cn.Open()

Dim cmd1 As New OleDbCommand

cmd1.Connection = cn

cmd1.CommandText = "SELECT System FROM Reference"

TextBox1.Text = cmd1.ExecuteScalar

End Sub

End Class

Running this program as a Windows application works fine, but running the
SAME code as a Web application returns
Server Error in '/WebTest01' Application.
----------------------------------------------------------------------------
----

'W:\PDB\Development\PDB.mdb' is not a valid path. Make sure that the path
name is spelled correctly and that you are connected to the server on which
the file resides.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException:
'W:\PDB\Development\PDB.mdb' is not a valid path. Make sure that the path
name is spelled correctly and that you are connected to the server on which
the file resides.

Source Error:
Line 30: Dim cn As New OleDbConnection
Line 31: cn.ConnectionString =
"provider=Microsoft.Jet.OLEDB.4.0;Data Source=W:\PDB\Development\PDB.mdb"
Line 32: cn.Open()
Line 33: Dim cmd1 As New OleDbCommand
Line 34: cmd1.Connection = cn
Source File: c:\inetpub\wwwroot\WebTest01\WebForm1.aspx.vb Line: 32

Stack Trace:
[OleDbException (0x80004005): 'W:\PDB\Development\PDB.mdb' is not a valid
path. Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.]
System.Data.OleDb.OleDbConnection.ProcessResults(I nt32 hr)
System.Data.OleDb.OleDbConnection.InitializeProvid er()
System.Data.OleDb.OleDbConnection.Open()
WebTest01.WebForm1.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\WebTest01\WebForm1.aspx.vb:32
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

----------------------------------------------------------------------------
----

Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573

Does this tell you anything?

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi John,

Did you see this page?
http://www.able-consulting.com/ADO_Conn.htm

And the link after obsolete almost at the bottom
Maybe that can help you?

Cor

Nov 20 '05 #19
Hi John,

Can you come to that access database using windows explorer?

Cor
Nov 20 '05 #20
Hi John,

You know that you are in a windows application an other user than with a web
application, that would be my only answer on this.

I do not know the user from the windows application, however from the web it
is of course your asp net user, has that right to access that mdb file?.

Sounds like this should be the problem.

Cor
Nov 20 '05 #21
I'll have to check with the administrator, who is out today.

I will reply again when I find out.

Thanks,

John
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eK**************@TK2MSFTNGP12.phx.gbl...
Hi John,

You know that you are in a windows application an other user than with a web application, that would be my only answer on this.

I do not know the user from the windows application, however from the web it is of course your asp net user, has that right to access that mdb file?.

Sounds like this should be the problem.

Cor

Nov 20 '05 #22

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Giulio Santorini | last post: by
reply views Thread by Alan Z. Scharf | last post: by
5 posts views Thread by Nick Flandry | last post: by
2 posts views Thread by adams114 | last post: by
3 posts views Thread by John Howard | last post: by
1 post views Thread by Hifni Shahzard | last post: by
15 posts views Thread by David | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.