public bool createDatasource(string localFilePath, string serverFolderPath, bool overWrite)
        {
            FileStream stream = File.OpenRead(localFilePath);

            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.Load(stream);

            var dataSourceName = Path.GetFileNameWithoutExtension(localFilePath);

            string connectionString = xmlDocument.SelectSingleNode("//ConnectString").InnerText;

            DataSourceDefinition definition = new DataSourceDefinition();
            definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated;
            definition.ConnectString = connectionString;
            definition.Enabled = true;
            definition.EnabledSpecified = true;
            definition.Extension = "SQL";
            definition.ImpersonateUserSpecified = false;

            definition.WindowsCredentials = true;

            try
            {
                ReportingService.CreateDataSource(dataSourceName, serverFolderPath, overWrite, definition, null);
            }
            catch (SoapException exception)
            {
                if (exception.Message.Contains("Microsoft.ReportingServices.Diagnostics.Utilities.ItemAlreadyExistsException"))
                {
                    Debug.Print(exception.Message);
                }
                else
                {
                    throw exception;
                }
            }

            return true;
        }
 /// <remarks/>
 public void CreateDataSourceAsync(string DataSource, string Parent, bool Overwrite, DataSourceDefinition Definition, Property[] Properties, object userState)
 {
     if ((this.CreateDataSourceOperationCompleted == null)) {
         this.CreateDataSourceOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateDataSourceOperationCompleted);
     }
     this.InvokeAsync("CreateDataSource", new object[] {
                 DataSource,
                 Parent,
                 Overwrite,
                 Definition,
                 Properties}, this.CreateDataSourceOperationCompleted, userState);
 }
 /// <remarks/>
 public void CreateDataSourceAsync(string DataSource, string Parent, bool Overwrite, DataSourceDefinition Definition, Property[] Properties)
 {
     this.CreateDataSourceAsync(DataSource, Parent, Overwrite, Definition, Properties, null);
 }
 public CatalogItem CreateDataSource(string DataSource, string Parent, bool Overwrite, DataSourceDefinition Definition, Property[] Properties)
 {
     object[] results = this.Invoke("CreateDataSource", new object[] {
                 DataSource,
                 Parent,
                 Overwrite,
                 Definition,
                 Properties});
     return ((CatalogItem)(results[0]));
 }
 /// <remarks/>
 public System.IAsyncResult BeginTestConnectForDataSourceDefinition(DataSourceDefinition DataSourceDefinition, string UserName, string Password, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("TestConnectForDataSourceDefinition", new object[] {
                 DataSourceDefinition,
                 UserName,
                 Password}, callback, asyncState);
 }
 /// <remarks/>
 public System.IAsyncResult BeginSetDataSourceContents(string DataSource, DataSourceDefinition Definition, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("SetDataSourceContents", new object[] {
                 DataSource,
                 Definition}, callback, asyncState);
 }
 /// <remarks/>
 public System.IAsyncResult BeginCreateDataSource(string DataSource, string Parent, bool Overwrite, DataSourceDefinition Definition, Property[] Properties, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("CreateDataSource", new object[] {
                 DataSource,
                 Parent,
                 Overwrite,
                 Definition,
                 Properties}, callback, asyncState);
 }
 /// <remarks/>
 public void TestConnectForDataSourceDefinitionAsync(DataSourceDefinition DataSourceDefinition, string UserName, string Password, object userState)
 {
     if ((this.TestConnectForDataSourceDefinitionOperationCompleted == null)) {
         this.TestConnectForDataSourceDefinitionOperationCompleted = new System.Threading.SendOrPostCallback(this.OnTestConnectForDataSourceDefinitionOperationCompleted);
     }
     this.InvokeAsync("TestConnectForDataSourceDefinition", new object[] {
                 DataSourceDefinition,
                 UserName,
                 Password}, this.TestConnectForDataSourceDefinitionOperationCompleted, userState);
 }
 /// <remarks/>
 public void TestConnectForDataSourceDefinitionAsync(DataSourceDefinition DataSourceDefinition, string UserName, string Password)
 {
     this.TestConnectForDataSourceDefinitionAsync(DataSourceDefinition, UserName, Password, null);
 }
 public bool TestConnectForDataSourceDefinition(DataSourceDefinition DataSourceDefinition, string UserName, string Password, out string ConnectError)
 {
     object[] results = this.Invoke("TestConnectForDataSourceDefinition", new object[] {
                 DataSourceDefinition,
                 UserName,
                 Password});
     ConnectError = ((string)(results[1]));
     return ((bool)(results[0]));
 }
 /// <remarks/>
 public void SetDataSourceContentsAsync(string DataSource, DataSourceDefinition Definition, object userState)
 {
     if ((this.SetDataSourceContentsOperationCompleted == null)) {
         this.SetDataSourceContentsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetDataSourceContentsOperationCompleted);
     }
     this.InvokeAsync("SetDataSourceContents", new object[] {
                 DataSource,
                 Definition}, this.SetDataSourceContentsOperationCompleted, userState);
 }
 /// <remarks/>
 public void SetDataSourceContentsAsync(string DataSource, DataSourceDefinition Definition)
 {
     this.SetDataSourceContentsAsync(DataSource, Definition, null);
 }
 public void SetDataSourceContents(string DataSource, DataSourceDefinition Definition)
 {
     this.Invoke("SetDataSourceContents", new object[] {
                 DataSource,
                 Definition});
 }