Showing posts with label mobile. Show all posts
Showing posts with label mobile. Show all posts

Monday, March 26, 2012

Pushing IMAGE from SQL CE onto SQL Server 2000

Hello!

We are trying to use RDA to Push an image field onto SQL Server 2000 from a mobile device, but are having problems. Does anyone have any experience with this? If so, maybe some sample code would be very much appreciated. (We have been struggling with this for a while).

byte[] imagearray = null;

string imagestring = "";

try

{

imagearray = (byte[])SQLCEDr.GetValue(SQLCEDr.GetOrdinal("CapturedImage"));

imagestring = System.Text.Encoding.Default.GetString(imagearray, 0, (imagearray.Length - 1));

}

catch (Exception ex)

{

MessageBox.Show(ex.Message);

}

sParameters = "'" + imagestring + "'" ;

try

{

rda.SubmitSql("EXEC sp_HH_WorkOrder_SuppliesUsed " + sParameters,scon);

}

Thanks,

Andy

Here’s the problem:

imagestring = System.Text.Encoding.Default.GetString(imagearray, 0, (imagearray.Length - 1));

This line would be valid for an array which contains text in the default encoding. But it contains binary image data which would be treated as text, corrupted and lost.

To insert/retrieve binary data you have to use parameterized query. In fact, you should use parameterized queries for everything - would save you lot of troubles with localization (e.g. infamous 10/25/2006 vs. 25.10.2006) and formatting not to mention more secure and better performing code. If you don't know how to use parameters, please look it up on MSDN or search this forum as it's been answered before.

Saturday, February 25, 2012

Publication Configuration Error

Hey Everyone,

I am trying to setup publishing on SQL Server 2000 Enterprise. I will be subscribing from a SQL Mobile 2005 database so I have installed the SQL Server 2000 SP3a Replication Components, .NET Framework 2.0, and the SQL Server 2005 Mobile Edition Server Tools.

I was able to go through the 2005 Mobile Web Synchronization Wizard with no problems. However, when I try to run the Configure Publishing and Distribution Wizard, I get the following message at the end:

SQL Server Enterprise Manager could not configure 'GISSERV' as the Distributor for 'GISSERV'
Error 14114: '(null)' is not configured as a Distributor.

The first option I choose is Make 'GISSERV' it's own Distributor. Then, I select the snapshot folder that I shared. And on the third screen, I've tried going with the standard default settings and customizing those settings.

Has anyone else come across this error? Is there anyone else out there replicating from SQL Server 2000 to SQL Server 2005 Mobile?

Thanks in advance,

Lee

Is this merge replication? If so, this configuration is not supported, you cannot have a SQL 2005 subscriber with a SQL 2000 publisher/distributor.

http://msdn2.microsoft.com/ms143241(en-US,SQL.90).aspx

|||

Thanks for the link. I'm going to have to find another way of doing this. I was led to believe that it was possible by this article:

http://www.microsoft.com/sql/editions/sqlmobile/connectivity-tools.mspx

But regardless of what my subscriber is running, I still should not be getting this error, should I?

Thanks,

Lee

|||hold on, i wasn't paying attention when you said SQL Server Mobile 2005. Let me double-check.|||

Yes, SQL 2005 Mobile is supported for a SQL 2000 publisher/distributor, I was incorrect.

Regarding the error message, have you renamed your machine along the way, or restored master database from a backup of another machine? Regardless, here's the KB article that most like fixes the situation:

http://support.microsoft.com/default.aspx?scid=kb;en-us;302223

Publication changes not appearing at subscriber?

I have setup a merge replication publication (SQL server 2005 wth SQL Mobile) with dynamic filters based on host name and when i sync to the pda all data appears fine. When I make changes on the PDA and synchronise, the changes are pushed back to the server fine.

However when I change data on the server and synchronise at the PDA, no changes ever appear!

Surely I must have missed something obvious or done something really stupid.

If i check the replication monitor it just says no changes so any suggestions would be great.

Thanks,

Andy

Ok, Ive managed to prove that if there is no @.subset_filterclause specified, it works fine. As soon as the filter is turned on i cannot add any new rows.

The filter is quite complex and as far as I can see, it will always fail because of the order in which records are added to the database. Can anybody clarify?

I have an organisation table and account management tables. The filter says download organisations that you are the account manager of. THerefore the organisation record is saved before the account management due to dependencies and at the point of creating the org, the trigger will fail because the account management record will not exist.

Surely this must be a standard problem so what am i doing wrong?

|||

After using one of our gold partner support calls, Microsoft have diagnosed the problem as my use of precomputed publications. This option in 2005 means that each insert fires a trigger which in turn evaluates the filter conditions.

In my case when i added a new organisation, it checked if the organisation was inside the users account management roles. This fails because the account management row has not yet been inserted (and cannot be added until after the org due to FK's.

The simple solution was to turn off precomputed partitions which sorted the problem.

Apparently it should be possible to use precomputed partitions if I define a row filter based on the last row to be inserted with all other rows linked through join filters. However, the suggested filters didnt work so I will try a bit more when i get an hour spare (in 2027 Wink )

Publication changes not appearing at subscriber?

I have setup a merge replication publication (SQL server 2005 wth SQL Mobile) with dynamic filters based on host name and when i sync to the pda all data appears fine. When I make changes on the PDA and synchronise, the changes are pushed back to the server fine.

However when I change data on the server and synchronise at the PDA, no changes ever appear!

Surely I must have missed something obvious or done something really stupid.

If i check the replication monitor it just says no changes so any suggestions would be great.

Thanks,

Andy

Ok, Ive managed to prove that if there is no @.subset_filterclause specified, it works fine. As soon as the filter is turned on i cannot add any new rows.

The filter is quite complex and as far as I can see, it will always fail because of the order in which records are added to the database. Can anybody clarify?

I have an organisation table and account management tables. The filter says download organisations that you are the account manager of. THerefore the organisation record is saved before the account management due to dependencies and at the point of creating the org, the trigger will fail because the account management record will not exist.

Surely this must be a standard problem so what am i doing wrong?

|||

After using one of our gold partner support calls, Microsoft have diagnosed the problem as my use of precomputed publications. This option in 2005 means that each insert fires a trigger which in turn evaluates the filter conditions.

In my case when i added a new organisation, it checked if the organisation was inside the users account management roles. This fails because the account management row has not yet been inserted (and cannot be added until after the org due to FK's.

The simple solution was to turn off precomputed partitions which sorted the problem.

Apparently it should be possible to use precomputed partitions if I define a row filter based on the last row to be inserted with all other rows linked through join filters. However, the suggested filters didnt work so I will try a bit more when i get an hour spare (in 2027 Wink )