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 RemoteAccess.Push("KeyHeader", RDAConnectingString, Data.SqlServerCe.RdaBatchOption.Batching Catch RDAConnectionException As Exception RemoteAccess.Dispose() TABLE DEFINITION: Anyone have any insight on a solution? Thanks. 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. 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)
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/sqlc
RemoteAccess.LocalConnectionString = "Data Source=Program Files\SQL Mobile\en\MobileKeyDB.sdf; Password = <mypassword>"
Cursor.Current = Cursors.WaitCursor
Try
MessageBox.Show("Can not push Header Data: " & RDAConnectionException.ToString, "Loading Key Tracker")
Finally
End Try
Cursor.Current = Cursors.Default
End Sub
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]
No comments:
Post a Comment