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

Tuesday, March 27, 2012

@@IDENTITY in code

Hi all,

I encountered a problem with SQL server mobile.

I am inserting a row inside a database table through C# code and need to obtain the ID of the last inserted row if successful. I have the following in my code:

SqlCeHelper.ExecuteNonQuery(connectionString, "*INSERT STATEMENT*");

Int64 id = (Int64)SqlCeHelper.ExecuteScalar(connectionString, "SELECT @.@.IDENTITY");

The variable id always ends up NULL. Is this the correct approach to this? Is there anything else I can use to obtain the id of the last inserted row in SQL server mobile?

-- The class SqlCeHelper is a wrapper that I wrote, it works 100%.

Thanks

you should be using Identity_Scope() - its better. I havent worked with SqlCE but this is what I use, and is best used than @.@.Identity, and no idea if this works for SqlCe

My apologies if it does not

I also believe, perhaps I am wrong again, that you are executing 2 different queries, hence why you are receiving null for your last query - again, I may well be totally wrong here. It's a learning curve for me also

|||

Hi,

No...unfortunately SQL mobile doesn't support the function.

I though of the two separate statements as well. Is it possible to run two different SQL statements inside one command?

Thanks

|||

OK,

Fixed the problem. It really was executing these two statements totally separately.

The correct way to fix this is to add a couple lines inside my SQLCeHelper...

I now have something like this inside the SQLCeHelper:

publicstaticobject ExecuteInsert(string connectionString, string command, paramsSqlCeParameter[] commandParameters){

object retval = null;

try{

SqlCeConnection cn = newSqlCeConnection(connectionString);

SqlCeCommand c = newSqlCeCommand(command, cn);

foreach (SqlCeParameter p in commandParameters)

c.Parameters.Add(p);

cn.Open();

c.ExecuteNonQuery();

c = newSqlCeCommand("SELECT @.@.IDENTITY AS [IDENTITY]", cn);

retval = c.ExecuteScalar();

}

catch

{

throw;

}

return retval;

}

sql

Sunday, March 25, 2012

Data transfer Pocket PC <> Desktop PC?

Hi,everyone!

I'm new to this forum and also new to Visual Studio 2005 .NET.

I'm going to develop a pocket pc(windows mobile 2005) application which needs to save some data introduced by the user.Later that data should be syncronized with MS SQL Server database.

The application is going to be developed using Visual Studio 2005 with c#.

So I'm doubting wich is the best way of syncronising the data between Pocket Pc and a Desktop PC.Should i use MS SQL Server Mobile(RDA,Merge Replication) or XML(Xml Web Services) would help me better?Or is there any other better way of data syncronization/storage?

Could anyone help me,or post some links + code samples,please?

Thanks!

You'll need to provide more information ... how much data? What sort of data? Will it need to be wrapped in a transaction and/or have other potential for rollback? How critical is it/how reliable does the synchronization need to be? Have you looked into the Service Broker? (I'm exploring this for a project myself.)

connect to distribution server

Need to be able to add data to a mobile with SQL2K
desktop edition and then manually replicate to SQL2K on
server. Can't access the distribution server from the
mobile.
Thoughts suggestions etc?
thanks
Sorry to ask the obvious, but is this when you are connected to the network?
Assuming it is, please can you clarify a few things:
the complete text of the error message,
the type of security configuration of your agents - are you logged onto the
domain, using pass-through security etc
can you 'see' the distribution server - pinging it by name will test this
Regards,
Paul Ibison
|||The distribution server is running on a SQLServer2K SE
machine running W2K OS. The remote is a laptop with
SQLServer2K PE. Both the remote and the server are
registered in EM respectively. They are both part of the
same workgroup but not a domain.
The problem arises when I attempt to use the Configure
Publishing, Subsribers and Distribution Wizard for the
laptop instance (SQLServer2K PE), The Select Distributor
dialogue has the "Use the following server..."
option "grayed-out" as is the "Add Server" button.
The only choice is to use the local machine as the
distributor which I don't want to do.
Is this a limitation of SQLServer2K PE or am I doing
something wrong with my configuration?
In the final anaylsis I need to be able to add data on
the laptop when not conncected to the server and then
manually synchronize when connected.
Thanks for your help
Thanks
>--Original Message--
>Sorry to ask the obvious, but is this when you are
connected to the network?
>Assuming it is, please can you clarify a few things:
>the complete text of the error message,
>the type of security configuration of your agents - are
you logged onto the
>domain, using pass-through security etc
>can you 'see' the distribution server - pinging it by
name will test this
>Regards,
>Paul Ibison
>
>.
>
|||The only restriction I was previously aware of is that SQL Server 2000
Personal Edition cannot be used as publisher for transactional replication.
However if you have a look at this link in BOL :
mk:@.MSITStore:C:\Program%20Files\Microsoft%20SQL%2 0Server\80\Tools\Books\rep
wizrd.chm::/repwizrd_97oi.htm
it seems you are correct. This is a limitation of Personal Edition.
However,
if you are running merge replication, the distinction between publisher and
subscriber in this regard is not so big, so having the mobile as a
subscriber is a posibility.
HTH,
Paul Ibison
|||Thanks. I suppose I will have to work with merge
replication.
>--Original Message--
>The only restriction I was previously aware of is that
SQL Server 2000
>Personal Edition cannot be used as publisher for
transactional replication.
>However if you have a look at this link in BOL :
>mk:@.MSITStore:C:\Program%20Files\Microsoft%20SQL%
20Server\80\Tools\Books\rep
>wizrd.chm::/repwizrd_97oi.htm
>it seems you are correct. This is a limitation of
Personal Edition.
>However,
>if you are running merge replication, the distinction
between publisher and
>subscriber in this regard is not so big, so having the
mobile as a
>subscriber is a posibility.
>HTH,
>Paul Ibison
>
>.
>

Thursday, March 8, 2012

.Net framework 1.0, SQL ce 2.0 and Windows mobile 5.0 work together?

Hi,

Does anyone know if I have created a replication using SQL Server 2000 (sp3a), .Netframework 1.0 with Pocket pc Sql Server CE 2.0 will work or not in pocket pc windows mobile 5.0 environment (with the .netframework for pocket pc(netcf.core.ppc3.arm.cab) and sql ce file (sqlce.ppc3.arm.CAB) installed in pocket pc)?

I have it working in pocket pc Windows mobile 2003 version. But, after I tried to install the exact same cab files and system into Windows mobile 5.0, the replication fail.

Anyone has any idea?

Hi AngelaC,

Same CABs do not work for both PPC 2003 and PPC 2005.

SQL CE 2.0 Cabs for PPC 2005 are shipped with VS 2005.

Also, SQL Mobile 3.0 is already relased and I am still wondering why you are not upgrading to this version when making a move to PPC 2005.

Thanks,

Laxmi Narsimha Rao ORUGANTI, SQL Ev, Microsoft Corporation

|||

Thanks Laxmi,

I will try to give it a try with SQL CE 2.0 Cabs from VS 2005 and let everyone knows if it works.

The reason I am not using SQL Mobile 3.0 is that the program has already been used in production for a year, I guess we won't modify it unless is necessary.

|||

Hi Laxmi,

I have installed VS5.0 and don't know which CAB to install. Following is my current environment that is working in production:

SQL Server 2000 with sp3a

Program in VS 2003 with .Net framework 1.0

For mobile: in Windows mobile 2003, installed "sqlce.ppc3.arm.cab" and "netcf.core.ppc3.arm.cab".

My question is which cab files (for both framework and sql ce) in VS2005 should I install in Windows mobile 5.0 to replace the 2 cab files I installed in Windows mobile 2003?

Thanks

Friday, February 24, 2012

.doc iFilter not working for Mobile docs

Hi,
I have implemented full text searching over files stored in a varbinary(max)
field and this works great
The only issue i am now having is that users creating office documents
created on a Windows Mobile device such as word docs are not being searched.
The extension is .doc but the files look cut down in size.
Does anyone know of a filter or filter update that will also search office
type files created on a Windows Mobile device?
Thanks,
Jeff
The iFilters are specific for document type. The PocketWord application does
not save it in a format that the Office iFilter can understand. You would be
better off to convert them to Word.
"Jeff" <Jeff@.discussions.microsoft.com> wrote in message
news:87EE86C3-0B73-4F23-B1C2-FCB85A15DF5B@.microsoft.com...
> Hi,
> I have implemented full text searching over files stored in a
> varbinary(max)
> field and this works great
> The only issue i am now having is that users creating office documents
> created on a Windows Mobile device such as word docs are not being
> searched.
> The extension is .doc but the files look cut down in size.
> Does anyone know of a filter or filter update that will also search office
> type files created on a Windows Mobile device?
> Thanks,
> Jeff
|||Hi Hilary,
Thanks for your answer.
What I find strange is that the device saves the document with the extension
..doc, but is not a true word document format. So when I check the file
extension with the supported SQL iFilter extensions I get a match and save it
in the db for indexing and searching.
How would I go about programaticaly converting the uploaded docs from the
mobile devices to the full Office document standard supported by the Office
iFilter?
Thanks for your help,
Jeff
"Hilary Cotter" wrote:

> The iFilters are specific for document type. The PocketWord application does
> not save it in a format that the Office iFilter can understand. You would be
> better off to convert them to Word.
> "Jeff" <Jeff@.discussions.microsoft.com> wrote in message
> news:87EE86C3-0B73-4F23-B1C2-FCB85A15DF5B@.microsoft.com...
>
>
|||You would have to use Word to convert the files to the Office Word document
format as opposed to the Pocket Word format.
"Jeff" <Jeff@.discussions.microsoft.com> wrote in message
news:20A3F7E8-C0C6-490A-B555-EAD7931C62E0@.microsoft.com...[vbcol=seagreen]
> Hi Hilary,
> Thanks for your answer.
> What I find strange is that the device saves the document with the
> extension
> .doc, but is not a true word document format. So when I check the file
> extension with the supported SQL iFilter extensions I get a match and save
> it
> in the db for indexing and searching.
> How would I go about programaticaly converting the uploaded docs from the
> mobile devices to the full Office document standard supported by the
> Office
> iFilter?
> Thanks for your help,
> Jeff
> "Hilary Cotter" wrote:

'.bcp file is corrupt' with dynamic snapshots

I have merge replication set up between sql mobile and sql 2005 (just recently upgraded from sql 2000). My publication has around 40 published tables, about half of them are filtered. The other day I noticed that the initial replication to get the entire database was downloading the same tables multiple times. The last test was each table was downloaded 10 times. So I did some research which brought me to the following fix, which was to implement dynamic snapshots.

However, when I try to replicate, it generates a dynamic snapshot, but it fails with the following error…

An error occurred while reading the .bcp data file for the 'MSmerge_rowtrack' article. If the .bcp file is corrupt, you must regenerate the snapshot before initializing the Subscriber.(Source: MSSQL_REPL, Error number: MSSQL_REPL-2147199428)

I haven’t changed the snapshot locations, and if I don’t use dynamic snapshots it works fine. I’ve tweaked the permissions (in development) to the point where everyone has full permission on the IIS share, and snapshot folder with no luck.

I would appreciate any advice. Thank you!

Not sure if you'll find an answer here.

I've been a part of this thread

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=100529&SiteID=1&PageID=0

without any real resolution so far.

We can re-run the snapshot when it happens and that seems to resolve it for the user who is affected, but if it's a permissoins problem why doesn;t it happen to everyone at once?

Thursday, February 9, 2012

(SQL Mobile)Can SELECT, but cannot INSERT/UPDATE. Why not?

I'm just getting started with using SQL Server Mobile while creating a handheld app using Visual Studio 2005. So far, I have succeeded in RETRIEVING data from the mobile database, but I don't understand why my INSERT nor UPDATE statements will not work. (I'm assuming they don't work, because after I run my code via the debugger, I oddly get no error message, but when I "open" the table in the Server Explorer, I do not see my expected results. Do I need to do some kind of "commit" or something? Here's my code. Thanks for any help! - Sue

-

'Create SQL statement:
Dim strSQL As String
strSQL = "INSERT INTO MyTable (col1, col2) VALUES ('yucky', 'poo')"

'Create DB connection:
Dim connDB As New System.Data.SqlServerCe.SqlCeConnection
connDB.ConnectionString = ("Data Source =" _
+ (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.GetName.CodeBase) + "\SueUWM.sdf;"))

'Create DB command:
Dim cmndDB As New System.Data.SqlServerCe.SqlCeCommand(strSQL, connDB)

'Open the connection:
connDB.Open()

'Execute the command:
Dim intRecordsAffected As Integer
Try
intRecordsAffected = cmndDB.ExecuteNonQuery()

If intRecordsAffected <> 1 Then
MessageBox.Show("Unable to insert into database.")
End If
Catch ex As Exception
MessageBox.Show(ex.ToString, "Insert Error")
End Try

'close the DB connection:

connDB.Close()

-

I am so dumb! I just learned that the insert & update modifications are made on the .sdf file on the emulator, and therefore will *not* be visible to me in Visual Studio's Server Explorer (on the desktop)! - Sue