Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Wednesday, March 7, 2012

RDA with Identity column.

Hi Everyone:

I am new to Mobile programming. I am now working on a mobile project. I encounter an issue when I sync the data:

cause I can't modify the schema, so I have to use RDA instead of Merge replication on sql server 2005.

However, There is an identiy column on each table I will pull them down to local mobile database. And I will use those identity columns to connect tables. Even worse, the photo's new name will combine the photoID which is an identity column. There would an issue, if i sync data, the photoID would be same on different local mobile databases. And there would be generate same identity value when users sync data.

How can I avoid those issues? If you have any good ideas, please help me out so that I can meet the project deadline.

Thanks

James

Anyone knows how to manually handle identity management.

Cause my identity column will clash when Sync data.

James

|||

You need to call

ALTER TABLE <TableName> ALTER COLUMN <ColumnName> <ColumnDataType> IDENTITY(<Seed>,<Step>)

to set the different identity on the pulled table.

Note, only Seed and Step can be changed in the above table.

Thanks,

Laxmi Narsimha Rao ORUGANTI

|||

Hi Laxmi,

Thank you for your reply. I realize that I can use the command you gave to change the SEED range to avoid the clash. But if I change seed, when I push the data back to Remote SQL server 2005 database, should I disable the identity column on remote database, then push mobile client table data, then set identity column back on remote DB. It seems lots of work to manually handle identity column clash. Do we have any alternative way to do it, since I can't use merge replication to change the database schema, what about XML web service? I think should be same, but if we use Web Service, the performance should be down 10-15%, that's why i don't wanna use it since we choose SQL server 2005 as our database.

Your reply is really appreciated. Thanks!

James

|||

I need to point is that someone will work on remote db through classical ASP. If I change the identity Seed. It will effect mobile client?

If anybody has the same issues?

Thanks

James

|||

No need to worry about disabling the IDENTITY on server. RDA while pushing automatically does "SET IDENTITY_INSERT <TableName> ON/OFF" on SQL Server to get the same IDENTITY column values onto the server table.

Thanks,

Laxmi

|||

Thank Laxmi,

your reply does help me. I will try it out. But we have 200 hundred of Mobile clients. We have to set the identity range for each one.

Any other good ideas for solving the identity clash.

Thanks.

James

|||That is why there is Merge Replication! Why not go for that?|||

Because I can't modify the Sql server 2005 DB schema. They are using identity ID. I wish I could use Merge replication. I can save my code lines as well.

Thank you . Laxmi. You are the rock!

James

|||Same here, merge replication is not a option.

Anyone found a suitable solution for this challenge?

Thanx
|||What I have done is to set the ID range for each person. So that they won't clash.

RDA with Identity column.

Hi Everyone:

I am new to Mobile programming. I am now working on a mobile project. I encounter an issue when I sync the data:

cause I can't modify the schema, so I have to use RDA instead of Merge replication on sql server 2005.

However, There is an identiy column on each table I will pull them down to local mobile database. And I will use those identity columns to connect tables. Even worse, the photo's new name will combine the photoID which is an identity column. There would an issue, if i sync data, the photoID would be same on different local mobile databases. And there would be generate same identity value when users sync data.

How can I avoid those issues? If you have any good ideas, please help me out so that I can meet the project deadline.

Thanks

James

Anyone knows how to manually handle identity management.

Cause my identity column will clash when Sync data.

James

|||

You need to call

ALTER TABLE <TableName> ALTER COLUMN <ColumnName> <ColumnDataType> IDENTITY(<Seed>,<Step>)

to set the different identity on the pulled table.

Note, only Seed and Step can be changed in the above table.

Thanks,

Laxmi Narsimha Rao ORUGANTI

|||

Hi Laxmi,

Thank you for your reply. I realize that I can use the command you gave to change the SEED range to avoid the clash. But if I change seed, when I push the data back to Remote SQL server 2005 database, should I disable the identity column on remote database, then push mobile client table data, then set identity column back on remote DB. It seems lots of work to manually handle identity column clash. Do we have any alternative way to do it, since I can't use merge replication to change the database schema, what about XML web service? I think should be same, but if we use Web Service, the performance should be down 10-15%, that's why i don't wanna use it since we choose SQL server 2005 as our database.

Your reply is really appreciated. Thanks!

James

|||

I need to point is that someone will work on remote db through classical ASP. If I change the identity Seed. It will effect mobile client?

If anybody has the same issues?

Thanks

James

|||

No need to worry about disabling the IDENTITY on server. RDA while pushing automatically does "SET IDENTITY_INSERT <TableName> ON/OFF" on SQL Server to get the same IDENTITY column values onto the server table.

Thanks,

Laxmi

|||

Thank Laxmi,

your reply does help me. I will try it out. But we have 200 hundred of Mobile clients. We have to set the identity range for each one.

Any other good ideas for solving the identity clash.

Thanks.

James

|||That is why there is Merge Replication! Why not go for that?|||

Because I can't modify the Sql server 2005 DB schema. They are using identity ID. I wish I could use Merge replication. I can save my code lines as well.

Thank you . Laxmi. You are the rock!

James

|||Same here, merge replication is not a option.

Anyone found a suitable solution for this challenge?

Thanx|||What I have done is to set the ID range for each person. So that they won't clash.

RDA with Identity column.

Hi Everyone:

I am new to Mobile programming. I am now working on a mobile project. I encounter an issue when I sync the data:

cause I can't modify the schema, so I have to use RDA instead of Merge replication on sql server 2005.

However, There is an identiy column on each table I will pull them down to local mobile database. And I will use those identity columns to connect tables. Even worse, the photo's new name will combine the photoID which is an identity column. There would an issue, if i sync data, the photoID would be same on different local mobile databases. And there would be generate same identity value when users sync data.

How can I avoid those issues? If you have any good ideas, please help me out so that I can meet the project deadline.

Thanks

James

Anyone knows how to manually handle identity management.

Cause my identity column will clash when Sync data.

James

|||

You need to call

ALTER TABLE <TableName> ALTER COLUMN <ColumnName> <ColumnDataType> IDENTITY(<Seed>,<Step>)

to set the different identity on the pulled table.

Note, only Seed and Step can be changed in the above table.

Thanks,

Laxmi Narsimha Rao ORUGANTI

|||

Hi Laxmi,

Thank you for your reply. I realize that I can use the command you gave to change the SEED range to avoid the clash. But if I change seed, when I push the data back to Remote SQL server 2005 database, should I disable the identity column on remote database, then push mobile client table data, then set identity column back on remote DB. It seems lots of work to manually handle identity column clash. Do we have any alternative way to do it, since I can't use merge replication to change the database schema, what about XML web service? I think should be same, but if we use Web Service, the performance should be down 10-15%, that's why i don't wanna use it since we choose SQL server 2005 as our database.

Your reply is really appreciated. Thanks!

James

|||

I need to point is that someone will work on remote db through classical ASP. If I change the identity Seed. It will effect mobile client?

If anybody has the same issues?

Thanks

James

|||

No need to worry about disabling the IDENTITY on server. RDA while pushing automatically does "SET IDENTITY_INSERT <TableName> ON/OFF" on SQL Server to get the same IDENTITY column values onto the server table.

Thanks,

Laxmi

|||

Thank Laxmi,

your reply does help me. I will try it out. But we have 200 hundred of Mobile clients. We have to set the identity range for each one.

Any other good ideas for solving the identity clash.

Thanks.

James

|||That is why there is Merge Replication! Why not go for that?|||

Because I can't modify the Sql server 2005 DB schema. They are using identity ID. I wish I could use Merge replication. I can save my code lines as well.

Thank you . Laxmi. You are the rock!

James

|||Same here, merge replication is not a option.

Anyone found a suitable solution for this challenge?

Thanx|||What I have done is to set the ID range for each person. So that they won't clash.

RDA Push with Identity column

Hi Everyone:

I am new to Mobile programming. I am now working on a small mobile app.

I encounter an issue when I sync the data:

Using RDA Pull, I can create the database and populate my table fine on my pocket pc device.

After updating the data on the device, I encounter an error when I try to Push my table back to the back-end SQL Server 2005 DB.

Error: "The identity range was not established."

VB CODE:
Private Sub RdaConnKeyHeaderPush()

Dim RemoteAccess As New Data.SqlServerCe.SqlCeRemoteDataAccess
Dim RDAConnectingString As String
RemoteAccess.InternetLogin = "<mylogin>"
RemoteAccess.InternetPassword = "<mypassword>"
RDAConnectingString = "Provider=SQLOLEDB;Persist Security Info=True;Data Source=<MySQLServer>;Initial Catalog=MobileKeyDB;" & _
"User ID=MobileUser;Password=<mypassword>"
RemoteAccess.InternetUrl = "https://www.<mysite>.com/SQLMobile/sqlcesa30.dll"
RemoteAccess.LocalConnectionString = "Data Source=Program Files\SQL Mobile\en\MobileKeyDB.sdf; Password = <mypassword>"
Cursor.Current = Cursors.WaitCursor
Try

RemoteAccess.Push("KeyHeader", RDAConnectingString, Data.SqlServerCe.RdaBatchOption.BatchingOn)

Catch RDAConnectionException As Exception
MessageBox.Show("Can not push Header Data: " & RDAConnectionException.ToString, "Loading Key Tracker")
Finally

RemoteAccess.Dispose()
End Try
Cursor.Current = Cursors.Default
End Sub

TABLE DEFINITION:
USE [MobileKeyDB]
GO
/****** Object: Table [dbo].[KeyHeader] Script Date: 07/11/2007 09:48:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[KeyHeader](
[trans_id] [int] IDENTITY(1,1) NOT NULL,
[user_id] [int] NOT NULL,
[date_stamp] [datetime] NOT NULL,
[signature] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[status] [int] NOT NULL,
[id] [int] NOT NULL,
[date_stamp2] [datetime] NOT NULL,
CONSTRAINT [PK_KeyHeader] PRIMARY KEY CLUSTERED
(
[trans_id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

Anyone have any insight on a solution? Thanks.

For synch scenarios, you should always avoid identity columns, for an elaboration, see http://blogs.msdn.com/synchronizer/archive/2007/06/28/stay-away-from-auto-increment-columns.aspx|||

Ok....then I will try using the unique identifier.

My problem is here that I am unsure of how to add the guid to my insert statement in my application.

I have a dataset created that has an Insert menthod for a my table.

How do I set the properties of this Insert statement to use a GUID in it's execution?

Thanks.

|||Modify your insert command to use NEWID(), see http://msdn2.microsoft.com/en-us/library/ms173249.aspx|||

Ok...thanks for your help.

I tried inserting the NEWID() method into my sql insert statement, however when I run my application in debug mode,

I get an Null Value Exception on that UniqueIdentifier field....what would the best way to identify where and why this is happening?

The error occurs when I try to close the form by clicking 'ok' after entering a record......

Error....

NoNullAllowedException was unhandled

Column 'ID' does not allow nulls.

Code Point where error is generated....

Private Sub KeysEditViewDialog_Closing(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

Me.KeysBindingSource.EndEdit()

End Sub

Some Dataset Code.....is the null error on the sql side or app side, I am not sure of this?

Me._adapter.InsertCommand = New System.Data.SqlServerCe.SqlCeCommand

Me._adapter.InsertCommand.Connection = Me.Connection

Me._adapter.InsertCommand.CommandText = "INSERT INTO Keys"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&" (key_number, key_desc, building, inv_qty,"& _

" avail_qty, id)"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"VALUES (@.p1, @.p2, @.p3, @.p4, @.p5, NEWID())"

Me._adapter.InsertCommand.CommandType = System.Data.CommandType.Text

param = New System.Data.SqlServerCe.SqlCeParameter

param.ParameterName = "@.p1"

param.Size = 100

param.IsNullable = true

param.SourceColumn = "key_number"

Me._adapter.InsertCommand.Parameters.Add(param)

param = New System.Data.SqlServerCe.SqlCeParameter

param.ParameterName = "@.p2"

param.Size = 100

param.IsNullable = true

param.SourceColumn = "key_desc"

Me._adapter.InsertCommand.Parameters.Add(param)

param = New System.Data.SqlServerCe.SqlCeParameter

param.ParameterName = "@.p3"

param.Size = 100

param.IsNullable = true

param.SourceColumn = "building"

Me._adapter.InsertCommand.Parameters.Add(param)

param = New System.Data.SqlServerCe.SqlCeParameter

param.ParameterName = "@.p4"

param.DbType = System.Data.DbType.Int32

param.Size = 4

param.IsNullable = true

param.SourceColumn = "inv_qty"

Me._adapter.InsertCommand.Parameters.Add(param)

param = New System.Data.SqlServerCe.SqlCeParameter

param.ParameterName = "@.p5"

param.Size = 100

param.IsNullable = true

param.SourceColumn = "avail_qty"

Me._adapter.InsertCommand.Parameters.Add(param)

RDA pull problem

Hi,

I am new to SQL Mobile programming. I am using SQL Server 2005 Mobile and SQL Express. I have a mobile windows application + .sdf file in the PDA. When i try to pull the table the first time, the table is successfully retrieved to PDA. When i try to pull the table again, i get the following error:

"An unexpected error has occured in TestDb.exe. Select quit and then restart this program, or sleect details for more information.

A duplicate value cannot be inserted into aunique index. [table Name=_sysRDASubscriptions, constraint name=c_LocalTableName] "

The above message indicates, that the table is existing in "_sysRDASubscriptions" table.

I tried dropping the table using SQL Explorer in PDA, but it didn't work out.

I am not sure of how to drop the existing table from the database programatically, and if I drop the table from the database, will this be cleared.

Please help me in resolving this issue. I am in desperate need of an urgent solution for this.

Thanks

Prasanna

You will need to drop the existing table before the next call to RDA.Pull. An error occurs if the table already exists.

Run the following command in SQL Mobile Query Analyzer

DROP TABLE < table_name >
Take a look at SQL Server 2005 Mobile Edition Books Online topic:
"Executing SQL Statements on the SQL Tab"

Thank you!

Syed N. Yousuf

Microsoft Developer Support Professional

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

|||

Hi Syed,

I have already tried dropping the table from SQL Mobile Query Analyzer, and i think even I have already mentioned in the message that i posted previously. So, it will be better if you can read the previous post in detail.

By the way regarding the issue, even after dropping the table using the

"DROP TABLE <TABLENAME>" Query using SQL Mobile Query Analyzer, I didn't succeed. And when i did the same programatically, i don't understand why i get a "Null Reference Exception". I queried the Information_Schema.tables and i found that after i execute the DROP command, the information_schema.tables doesn't have any entries regarding the deleted table. Even after this i get the error. I am not sure how to delete the entries from the _sysRDASubscriptions table. Is it possible to execute queries against this table, either programmatically or manually. Suggest, a method to solve this issue.

Thanks

Prasanna.

|||

Are you really using SQL Express as the source of the tables you are trying to pull? If so, RDA from SQL Mobile to SQL Express is not a licensed or supported scenario.

-Darren Shaffer

|||

Hi Darren,

Our applications have both trial and paid versions. For paid versions, we will be not be using SQL Express, but for trial versions, we need to have SQL Express. So, I need a solution for both SQL Express and other editions as well.

Thanks

Prasanna

|||

About the only way to synchronize data from SQL Mobile to SQL Express is going to be to expose some simple web services that get and put data from/to the SQL Express database. Unlike MSDE, SQL Express has no SQL Agent and hence cannot support merge replication or RDA.

-Darren

RDA pull problem

Hi,

I am new to SQL Mobile programming. I am using SQL Server 2005 Mobile and SQL Express. I have a mobile windows application + .sdf file in the PDA. When i try to pull the table the first time, the table is successfully retrieved to PDA. When i try to pull the table again, i get the following error:

"An unexpected error has occured in TestDb.exe. Select quit and then restart this program, or sleect details for more information.

A duplicate value cannot be inserted into aunique index. [table Name=_sysRDASubscriptions, constraint name=c_LocalTableName] "

The above message indicates, that the table is existing in "_sysRDASubscriptions" table.

I tried dropping the table using SQL Explorer in PDA, but it didn't work out.

I am not sure of how to drop the existing table from the database programatically, and if I drop the table from the database, will this be cleared.

Please help me in resolving this issue. I am in desperate need of an urgent solution for this.

Thanks

Prasanna

You will need to drop the existing table before the next call to RDA.Pull. An error occurs if the table already exists.

Run the following command in SQL Mobile Query Analyzer

DROP TABLE < table_name >
Take a look at SQL Server 2005 Mobile Edition Books Online topic:
"Executing SQL Statements on the SQL Tab"

Thank you!

Syed N. Yousuf

Microsoft Developer Support Professional

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

|||

Hi Syed,

I have already tried dropping the table from SQL Mobile Query Analyzer, and i think even I have already mentioned in the message that i posted previously. So, it will be better if you can read the previous post in detail.

By the way regarding the issue, even after dropping the table using the

"DROP TABLE <TABLENAME>" Query using SQL Mobile Query Analyzer, I didn't succeed. And when i did the same programatically, i don't understand why i get a "Null Reference Exception". I queried the Information_Schema.tables and i found that after i execute the DROP command, the information_schema.tables doesn't have any entries regarding the deleted table. Even after this i get the error. I am not sure how to delete the entries from the _sysRDASubscriptions table. Is it possible to execute queries against this table, either programmatically or manually. Suggest, a method to solve this issue.

Thanks

Prasanna.

|||

Are you really using SQL Express as the source of the tables you are trying to pull? If so, RDA from SQL Mobile to SQL Express is not a licensed or supported scenario.

-Darren Shaffer

|||

Hi Darren,

Our applications have both trial and paid versions. For paid versions, we will be not be using SQL Express, but for trial versions, we need to have SQL Express. So, I need a solution for both SQL Express and other editions as well.

Thanks

Prasanna

|||

About the only way to synchronize data from SQL Mobile to SQL Express is going to be to expose some simple web services that get and put data from/to the SQL Express database. Unlike MSDE, SQL Express has no SQL Agent and hence cannot support merge replication or RDA.

-Darren