Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Wednesday, March 28, 2012

Replication Error

Hi all,

I have encountered an error during replication. The following is my code;


Try

m_SQlEngine = New SqlServerCe.SqlCeEngine("Data Source =\Project_JobLogger.sdf")

m_SQlEngine.CreateDatabase()

Dim SqlCeConnection As New SqlServerCe.SqlCeConnection("Data Source =\Project_JobLogger.sdf")

m_SQLConnection.Open()

Dim Repl As SqlServerCe.SqlCeReplication

Repl = New SqlServerCe.SqlCeReplication

Repl.InternetUrl = http://Ganges/PJLogger/sqlcesa30.dll

Repl.Publisher = "Ganges"

Repl.PublisherDatabase = "Project_JobLogger"

Repl.Publication = "PJLPublisher"

Repl.Subscriber = System.Net.Dns.GetHostName

Repl.SubscriberConnectionString = m_SQLConnection.ConnectionString

Repl.HostName = System.Net.Dns.GetHostName

Repl.ExchangeType = ExchangeType.BiDirectional

Repl.Synchronize()

Catch ex As Exception

MessageBox.Show(ex.ToString())

m_SQLConnection.Close()

m_SQLConnection.Dispose()

End Try


The error just displays - System.Data.SqlServerCe.SqlCeException;SqlCeException

Can anyone state what is the problem please?

Thanks

Matt

Matt,

There is a lot more information hiding inside the SqlCeException that is being thrown that you'll need to troubleshoot this situation. Here is some code to unwrap the exception and get specifics.

Public Sub DisplaySQLCEErrors(ByVal ex As SqlCeException)

Dim errorCollection As SqlCeErrorCollection = ex.Errors
Dim bld As New StringBuilder()
Dim inner As Exception = ex.InnerException
Dim err As SqlCeError

For Each err In errorCollection

bld.Append(ControlChars.Lf + " Error Code: " + err.HResult.ToString())
bld.Append(ControlChars.Lf + " Message : " + err.Message)
bld.Append(ControlChars.Lf + " Minor Err.: " + err.NativeError.ToString())
bld.Append(ControlChars.Lf + " Source : " + err.Source)

Dim numPar As Integer
For Each numPar In err.NumericErrorParameters
If (numPar <> 0) Then
bld.Append(ControlChars.Lf + " Num. Par. : " + numPar.ToString())
End If
Next numPar
Dim errPar As String
For Each errPar In err.ErrorParameters
If (errPar <> String.Empty) Then
bld.Append(ControlChars.Lf + " Err. Par. : " + errPar)
End If
Next errPar

MessageBox.Show(bld.ToString(), "SQL Mobile Error")

Next err

End Sub

-Darren

|||

Thanks a lot Darren, I found your piece of code very useful. It managed to specify the exact error

Thanks Again ,

Matt

Friday, March 23, 2012

replication between sql 2005 and sql ce

i'm new to smart device applications programing

i want the code used in vb.net to replicate a database between sql server 2005 and the sql ce used in the emulator of visual studio 2005

and plz if i can get all the technical advises so that my project could run prorely

(plz if i can get the code as soon as possible)

There are sample codes in BOL of CE and also on msdn.