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
No comments:
Post a Comment