Its been four days... the problem still persists man! I am sick of it. How much time is needed to refresh ? I will post my code so that you tell me if something is wrong there (i got this code from the SQL replication sample provided by Microsoft when we install SQL Server 2000)
Private Function CreatePublisher() As Boolean
Dim objSQLServer As SQLServer2
Dim objPublisher As DistributionPublisher2
Dim objRegSubscriber As RegisteredSubscriber
Dim intIndex As Integer
Try
'Getting the connection string from Access database
m_dtMaster = GetDataSet("SELECT * FROM tbl_Master_Servers_Info WHERE Master_Server_ID = '" & cboMasterServer.SelectedItem.ToString & "'", _
"tbl_Master_Servers_Info", , , False, m_strMDBConnStr).Tables(0)
m_strMasterConnStr = m_dtMaster.Rows(0)("Connection_String").ToString
m_strMasterServerName = m_strMasterConnStr.Split(";".ToCharArray)(0).Split("=".ToCharArray)(1)
m_strMasterDatabase = m_strMasterConnStr.Split(";".ToCharArray)(1).Split("=".ToCharArray)(1)
m_strMasterUserID = m_strMasterConnStr.Split(";".ToCharArray)(2).Split("=".ToCharArray)(1)
m_strMasterPassword = m_strMasterConnStr.Split(";".ToCharArray)(3).Split("=".ToCharArray)(1)
'Get the SQL Server that will be acting as Master (Publisher)
objSQLServer = New SQLDMO.SQLServer2
'Connect to SQL Server Distributor
objSQLServer.Connect(m_strMasterServerName, m_strMasterUserID, m_strMasterPassword)
'Get the drive and dir info
m_strMasterWorkingDir = objSQLServer.Registry.SQLRootPath & "\repldata"
'Create Distribution Publisher
objPublisher = New DistributionPublisher2
objPublisher.Name = "SAMPLE"
objPublisher.DistributionDatabase = "distribution" 'Distribution Database Name
objPublisher.ThirdParty = True
'objPublisher.DistributionWorkingDirectory = m_strMasterWorkingDir
Dim ddb As DistributionDatabase
ddb = New DistributionDatabase
ddb.Name = "distribution"
objSQLServer.Replication.Distributor.DistributionDatabases.Add(ddb)
'Add the Distribution Publisher to the SQL Server's Replication collection
objSQLServer.Replication.Distributor.DistributionPublishers.Add(objPublisher)
'objSQLServer.Replication.Distributor.DistributionPublishers.Item(1).Refresh()
'Create Subscribers
For intIndex = 0 To lstTransServers.Items.Count - 1
objRegSubscriber = New RegisteredSubscriber
objRegSubscriber.Name = lstTransServers.Items(intIndex).ToString
objRegSubscriber.Type = SQLDMO_SUBSCRIBER_TYPE.SQLDMOSubInfo_SQLServer
'Add the subscriber to the Publishers' collection
'###The line of error ###
objPublisher.RegisteredSubscribers.Add(objRegSubscriber)
'###The line of error ###
objRegSubscriber = Nothing
Next
objSQLServer.Close()
Return True
Catch ex As Exception
objPublisher = Nothing
objRegSubscriber = Nothing
objSQLServer.Close()
Return False
Finally
objPublisher = Nothing
objRegSubscriber = Nothing
objSQLServer = Nothing
End Try
End Function
Kindly tell me whether the code has something to do with the error.
Prakash.