K
Kam
Hi everyone,
Im new to SQL Server CE Agent, i've used the tutorial in (SQL Server CE Database Development with the .NET Compact Framework - Rob Tiffany)
however, everytime i try to pull using the set of code below an error occurs (An internal error occured. [ID,,,,,])
//----------------------
private void btnPull_Click(object sender, System.EventArgs e)
{
SqlCeConnection cn = null;
SqlCeRemoteDataAccess rda = null;
SqlCeEngine sqlEngine = null;
try
{
btnPull.Enabled = false;
// Create database if it doesn't already exist
if (!File.Exists("\\My Documents\\IntelligenceData.sdf"))
{
sqlEngine = new SqlCeEngine();
sqlEngine.LocalConnectionString = "Data Source=\\My Documents\\" +
"IntelligenceData.sdf";
//"Encrypt Database=False";
sqlEngine.CreateDatabase();
sqlEngine.Dispose();
}
else
{
// Open the connection to the database
cn = new SqlCeConnection("Data Source=\\My Documents\\" +
"IntelligenceData.sdf");
cn.Open();
SqlCeCommand cmd = cn.CreateCommand();
// Drop the FieldMemos table
cmd.CommandText = "DROP TABLE FieldMemos";
cmd.ExecuteNonQuery();
// Close the connection
if (cn.State != ConnectionState.Closed)
{
cn.Close();
}
}
// Instantiate the RDA Object
rda = new SqlCeRemoteDataAccess();
// Connection String to the SQL Server.
string remoteConnectString = "Provider=OLEDB;" +
"Data Source=MyComputerName;" +
"Initial Catalog=IntelligenceData";
//rda.InternetLogin = "Kamal Ali";//"robtiffany";
//rda.InternetPassword = "osamah";//"pinnacle";
rda.InternetUrl = http://tmg1356/fieldagentrda/sscesa20.dll;
rda.LocalConnectionString = "Data Source=\\My Documents\\" +
"IntelligenceData.sdf";//;" +
//"SSCEatabase Password=osamah";
rda.Pull("FieldMemos", "Select * from FieldMemos", remoteConnectString,
RdaTrackOption.TrackingOnWithIndexes, "FieldMemosErrorTable");
}
catch(SqlCeException sqlex)
{
foreach(SqlCeError sqlError in sqlex.Errors)
{
MessageBox.Show(sqlError.Message, "Error");
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Error");
}
finally
{
rda.Dispose();
btnPull.Enabled = true;
}
}
//--------------------------
and when i use the "SSCEatabase Password=osamah";
the following error message comes up:
( SQL Server CE encountered problems in opening the SQL Server CE database. [,,,Database name,,]" )
Any idea where im going wrong, keep in mind that im using Anonymous access in the SQL Server CE Agent which doesn't require User name and password to access the resouce. in addition, the table is created in using SQL Server Enterprise Manager.
Any help would be very much appreciated
Thanks in advance.
Kam
Im new to SQL Server CE Agent, i've used the tutorial in (SQL Server CE Database Development with the .NET Compact Framework - Rob Tiffany)
however, everytime i try to pull using the set of code below an error occurs (An internal error occured. [ID,,,,,])
//----------------------
private void btnPull_Click(object sender, System.EventArgs e)
{
SqlCeConnection cn = null;
SqlCeRemoteDataAccess rda = null;
SqlCeEngine sqlEngine = null;
try
{
btnPull.Enabled = false;
// Create database if it doesn't already exist
if (!File.Exists("\\My Documents\\IntelligenceData.sdf"))
{
sqlEngine = new SqlCeEngine();
sqlEngine.LocalConnectionString = "Data Source=\\My Documents\\" +
"IntelligenceData.sdf";
//"Encrypt Database=False";
sqlEngine.CreateDatabase();
sqlEngine.Dispose();
}
else
{
// Open the connection to the database
cn = new SqlCeConnection("Data Source=\\My Documents\\" +
"IntelligenceData.sdf");
cn.Open();
SqlCeCommand cmd = cn.CreateCommand();
// Drop the FieldMemos table
cmd.CommandText = "DROP TABLE FieldMemos";
cmd.ExecuteNonQuery();
// Close the connection
if (cn.State != ConnectionState.Closed)
{
cn.Close();
}
}
// Instantiate the RDA Object
rda = new SqlCeRemoteDataAccess();
// Connection String to the SQL Server.
string remoteConnectString = "Provider=OLEDB;" +
"Data Source=MyComputerName;" +
"Initial Catalog=IntelligenceData";
//rda.InternetLogin = "Kamal Ali";//"robtiffany";
//rda.InternetPassword = "osamah";//"pinnacle";
rda.InternetUrl = http://tmg1356/fieldagentrda/sscesa20.dll;
rda.LocalConnectionString = "Data Source=\\My Documents\\" +
"IntelligenceData.sdf";//;" +
//"SSCEatabase Password=osamah";
rda.Pull("FieldMemos", "Select * from FieldMemos", remoteConnectString,
RdaTrackOption.TrackingOnWithIndexes, "FieldMemosErrorTable");
}
catch(SqlCeException sqlex)
{
foreach(SqlCeError sqlError in sqlex.Errors)
{
MessageBox.Show(sqlError.Message, "Error");
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Error");
}
finally
{
rda.Dispose();
btnPull.Enabled = true;
}
}
//--------------------------
and when i use the "SSCEatabase Password=osamah";
the following error message comes up:
( SQL Server CE encountered problems in opening the SQL Server CE database. [,,,Database name,,]" )
Any idea where im going wrong, keep in mind that im using Anonymous access in the SQL Server CE Agent which doesn't require User name and password to access the resouce. in addition, the table is created in using SQL Server Enterprise Manager.
Any help would be very much appreciated
Thanks in advance.
Kam