472,353 Members | 1,390 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 1787
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Krung Saengpole | last post by:
Hi, I used SQL Server 2000 Personal Edition. I created a stored procedure having input parameters as smallint,tinyint,char,varchar and...
3
by: Giulio Santorini | last post by:
Hi, I've got a little problem with my C# WinForms test application. I would like to have a ComboBox showing a a visual value and some hidden...
0
by: Alan Z. Scharf | last post by:
Win Server 2003 VS.Net 2003 --------------- 1. I'm having the same problem below on all six of my pages with a datagrid item. 2. These pages...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a...
2
by: adams114 | last post by:
I am having a strange problem with invalid type casts. I am trying to update a MS SQL Database with a stored procedure. When I setup the parameters...
3
by: John Howard | last post by:
Making the following call to a local MSAccess database works fine: Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) Dim intRows...
1
by: Hifni Shahzard | last post by:
Hi, I got a stored procedure, where it returns a value. But if I execute it. It gives an error as "Invalid cast from System.Int32 to System.Byte."....
15
by: David | last post by:
Hi, I have built a web application that will be a very high profile application. We had tested it, demonstrated it and shown that it all works. ...
7
by: Chris Thunell | last post by:
I'm trying to loop through an exchange public folder contact list, get some information out of each item, and then put it into a vb.net datatable. ...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.