Mombu the Microsoft Forum sponsored links

Go Back   Mombu the Microsoft Forum > Microsoft > Remote Provider Problems
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 22nd January 00:41
mike
External User
 
Posts: 1
Default Remote Provider Problems



I was trying to create a DTS package to copy a table from
a Client's Access Databases...that didn't go well, so I
decided to write a console app in C# and use the
OleDbConnection, DataAdapter, etc. to select against the
MS Access table and insert it into my SQL Server 2000
using ADO.NET. But, I keep getting a silly error
Specified cast is not valid. My code looks like this:

string sConnect = @"Provider=MS Remote;Remote
Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=\\\\"A PUBLIC IP ADDRESS"\\myDB.mdb;Remote
Server="A PUBLIC IP ADDRESS";";
string sSQL = "SELECT * FROM Bid_Web_File";
DataTable dt = new DataTable();
OleDbConnection oConn;
OleDbDataAdapter oDA;

try
{
oConn = new OleDbConnection(sConnect);
oConn.Open();
oDA = new OleDbDataAdapter(sSQL, oConn);
oDA.Fill( dt );//where the error occurs
oDA.Dispose();
}
....

Here is the stack trace that I get:
STACK TRACE:
at System.Data.OleDb.OleDbException..ctor(IErrorInfo
errorInfo, Int32 errorCode, Exception inner)
at System.Data.OleDb.OleDbConnection.ProcessResults(I nt32
hResult, OleDbConnection connection, Object src)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHand
ling(Int32 hr)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingle
Result(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText
(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand
(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al
(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader
(CommandBehavior behavior)
at
System.Data.OleDb.OleDbCommand.System.Data.IDbComm and.Exec
uteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillFromCommand
(Object data, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbComma
nd command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,
Int32 startRecord, Int32 maxRecords, String srcTable,
IDbCommand comm
and, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at APW.DowntownSpokaneTransferDB.UpdateDB.Main(String []
args)

This is an app that is going to run every night. I would
really appreciate some help.
  Reply With Quote


  sponsored links


2 22nd January 00:41
scotr
External User
 
Posts: 1
Default Remote Provider Problems



Beyond this one line I will not stress how bad an idea it is to use RDS with .Net (Or even in general) and that you should use a Web service instead...

You may be running into a Permissions issue and the Invalid Cast error is bogus. Perhaps using Regmon and Filemon (http://www.sysinternals.com) to see if there are any entries where
you are getting an Access Denied.

It could also be something to do with the datatypes of the fields, Perhaps you could do something other than Select * (Like just pull in a couple of fields Select Field1, Field2 from
Table) and see if that works. If it does add fields until you get to the one that makes it fail.

Want to know more? Check out the MSDN Library at http://msdn.microsoft.com or the Microsoft Knowledge Base at http://support.microsoft.com

Scot Rose, MCSD
Microsoft Visual Basic Developer Support
Email : scotr@online.microsoft.com <Remove word online. from address>

This posting is provided “AS IS”, with no warranties, and confers no rights.


--------------------
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666