SQL Server CE encountered problems in creating the SQL Sever CE database



My exploit environment:
VS.net 2003, SQL Server 2000 SP4, SQL Server CE 2.0 SP4

I write next codes:
Private cn As New SqlCeConnection("data source=\my
documents\SQLCECF.sdf")

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
If Not System.IO.File.Exists("\my documents\SQLCECF.sdf")
Then
Dim en As New SqlCeEngine("data source=\my
documents\SQLCECF.sdf")
en.CreateDatabase() 'create a blank database to
subscribe
Synch()
End If
Catch err As SqlCeException
ShowErrors(err)
Catch err As Exception
MsgBox("There was an error:" & err.ToString())
End Try
End Sub

Sub Synch()
Try
Dim rep As SqlCeReplication = New SqlCeReplication
With rep
.Publisher = "192.168.0.222"
.PublisherDatabase = "CFLab"
.PublisherLogin = "sa"
.PublisherPassword = "sa"
.Publication = "CFLab"
.Subscriber = "SQLCENETCF"
.SubscriberConnectionString =
"Provider=Microsoft.SQLServer.OLEDB.CE.2.0;Data Source=\My
Documents\SQLCECF.sdf"
.InternetUrl = "http://192.168.0.222/SQLCE/sscesa20.dll";
' Create the Local SSCE Database subscription
rep.AddSubscription(AddOption.CreateDatabase)
rep.Synchronize() 'subscribe
End With

Catch err As SqlCeException
ShowErrors(err)
Finally

End Try
End Sub

Public Sub ShowErrors(ByRef e As SqlCeException)

Dim errorCollection As SqlCeErrorCollection = e.Errors
Dim bld As System.Text.StringBuilder = New
System.Text.StringBuilder
Dim inner As Exception = e.InnerException

If Not inner Is Nothing Then
MessageBox.Show(("Inner Exception:" & inner.ToString()))
End If

For Each err As SqlCeError In errorCollection
bld.Append("/n Error Code: " + err.HResult.ToString("X",
System.Globalization.CultureInfo.CurrentCulture))
bld.Append("/n Message : " + err.Message)
bld.Append("/n Minor Err.: " + err.NativeError.ToString())
bld.Append("/n Source : " + err.Source)

For Each numPar As Int32 In err.NumericErrorParameters

If 0 <> numPar Then
bld.Append("/n Num. Par. : " + numPar.ToString())
End If

Next

For Each errPar As String In err.ErrorParameters

If String.Empty <> errPar Then
bld.Append("/n Err. Par. : " + errPar)
End If

Next errPar

MessageBox.Show(bld.ToString())
bld.Remove(0, bld.Length)

Next err
End Sub

Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnShow.Click
connect()

Dim query As String = "select * from FlightData"
Dim dap As New SqlCeDataAdapter(query, cn)
Dim dataset1 As New DataSet
dap.Fill(dataset1, "FlightData")

Disconnect()
End Sub
Sub connect()
Synch()
Try
cn.Open()
Catch err As SqlCeException
ShowErrors(err)
End Try
End Sub
Sub Disconnect()
Try
cn.Close()
Catch err As SqlCeException
ShowErrors(err)
End Try
End Sub

Private Sub dgdResults_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles dgdResults.Click

End Sub
End Class

I want to synchronize the data from a SQLCE SERVER 2000
When i run the code above, the errors show:
Error Code:80040E17
Message:SQL Server CE encountered problems in creating the SQL Sever CE
database.

Error Code:80040E17
A data source with the specified name already exists.

I do not know what's going wrong..=(
Who can help me??!!! HELP~~~~~~~~~
thanks..




*** Sent via Developersdex http://www.developersdex.com ***
.



Relevant Pages

  • Re: error handling question
    ... Sub AAA ... Dim err_ As ErrObject ... Dim UserName As String ...
    (microsoft.public.excel.programming)
  • RE: error handling question
    ... Sub AAA ... Dim err_ As ErrObject ... Dim UserName As String ...
    (microsoft.public.excel.programming)
  • RE: scroll a few columns at a time
    ... Thank you very much, FST1. ... Ran out of sheet going right.") never ... Private Sub CB1_Click ... On Error GoTo err ...
    (microsoft.public.excel.programming)
  • Image::Magick - size limitation?
    ... I am using the following script to manage image database. ... croak "Cannot find image $id" unless defined; ... sub display_gallery ... $err" if $err; ...
    (comp.lang.perl.modules)
  • Re: Re-Post Find value of cell in another sheet
    ... Public Sub LookLeft() ... Dim sSheetName As String ... If Err 0 Then ...
    (microsoft.public.excel.programming)

Loading