Search Results

Search found 7 results on 1 pages for 'madlan'.

Page 1/1 | 1 

  • Merge\Combine two datatables

    - by madlan
    I'm trying to merge\combine two datatables. I've looked at various examples and answers but they seem to create duplicate rows or require indexes (merge on datatable etc) I can't do this via SQL as one source is from a linked Oracle server accessed via MSSQL and the other from a different MSSQL Server that does not have linked access. The data is currently very simple: Name, Email, Phone DataTable1: "John Clark", "", "01522 55231" "Alex King", "[email protected]", "01522 55266" "Marcus Jones", "[email protected]", "01522 55461" DataTable2: "John Clark", "[email protected]", "01522 55231" "Alex King", "[email protected]", "" "Marcus Jones", "[email protected]", "01522 55461" "Warren bean", "[email protected]", "01522 522311" Giving a datatable with the following: "John Clark", "[email protected]", "01522 55231" "Alex King", "[email protected]", "01522 55266" "Marcus Jones", "[email protected]", "01522 55461" "Warren bean", "[email protected]", "01522 522311" Name is the field to match records on, with the first datatable taking priority.

    Read the article

  • ado.net managing connections

    - by madlan
    Hi, I'm populating a listview with a list of databases on a selected SQL instance, then retrieving a value from each database (It's internal product version, column doesn't always exist) I'm calling the below function to populate the second column of the listview: item.SubItems.Add(DBVersionCheck(serverName, database.Name)) Function DBVersionCheck(ByVal SelectedInstance As String, ByVal SelectedDatabase As String) Dim m_Connection As New SqlConnection("Server=" + SelectedInstance + ";User Id=sa;Password=password;Database=" + SelectedDatabase) Dim db_command As New SqlCommand("select Setting from SystemSettings where [Setting] = 'version'", m_Connection) Try m_Connection.Open() Return db_command.ExecuteScalar().trim m_Connection.Dispose() Catch ex As Exception 'MessageBox.Show(ex.Message) Return "NA" Finally m_Connection.Dispose() End Try End Function This works fine except it's creating a connection to each database and leaving it open. My understanding is the close()\dispose() releases only the connection from the pool in ado rather than the actual connection to sql. How would I close the actual connections after I've retrieved the value? Leaving these open will create hundreds of connections to databases that will probably not be used for that session.

    Read the article

  • Controlling 3rd party program.

    - by madlan
    Hi my program launches a 3rd party program with a few switches to update itself. Once these updates are complete I need to manually click save from the applications menu. This can be done via the keyboard (Alt Gr + M then Alt Gr + S) The application will take several seconds to load at which point the application will open maximised and the save option will be enabled. Can anyone suggest a method or example for doing such a thing? Monitoring a lauched process? Macro? Thanks.

    Read the article

  • Restoring database with SMO - Reporting progress problems

    - by madlan
    I'm using the below to restore a database in VB.NET. This works but causes the interface to lockup if the user clicks anything. Also, I cannot get the progress label to update incrementally, it's blank until the backup is complete then displays 100% Sub DoRestore() Dim svr As Server = New Server("Server\SQL2008") Dim res As Restore = New Restore() res.Devices.AddDevice("C:\MyDB.bak", DeviceType.File) res.Database = "MyDB" res.RelocateFiles.Add(New RelocateFile("MyDB_Data", "C:\MyDB.mdf")) res.RelocateFiles.Add(New RelocateFile("MyDB_Log", "C:\MyDB.ldf")) res.PercentCompleteNotification = 1 AddHandler res.PercentComplete, AddressOf ProgressEventHandler res.SqlRestore(svr) End Sub Private Sub ProgressEventHandler(ByVal sender As Object, ByVal e As PercentCompleteEventArgs) Label3.Text = "" ProgressBar.Value = e.Percent LblProgress.Text = e.Percent.ToString End Sub

    Read the article

  • Calling Sub from EventHandler

    - by madlan
    I'm using the below to update controls from another thread (works great) How would I call a Sub (Named UpdateList)? The UpdateList updates a listview with a list of databases on a selected SQL instance, requires no arguments. Private Sub CompleteEventHandler(ByVal sender As Object, ByVal e As Microsoft.SqlServer.Management.Common.ServerMessageEventArgs) SetControlPropertyValue(Label8, "text", e.ToString) UpdateList() MessageBox.Show("Restore Complete") End Sub Delegate Sub SetControlValueCallback(ByVal oControl As Control, ByVal propName As String, ByVal propValue As Object) Private Sub SetControlPropertyValue(ByVal oControl As Control, ByVal propName As String, ByVal propValue As Object) If (oControl.InvokeRequired) Then Dim d As New SetControlValueCallback(AddressOf SetControlPropertyValue) oControl.Invoke(d, New Object() {oControl, propName, propValue}) Else Dim t As Type = oControl.[GetType]() Dim props As PropertyInfo() = t.GetProperties() For Each p As PropertyInfo In props If p.Name.ToUpper() = propName.ToUpper() Then p.SetValue(oControl, propValue, Nothing) End If Next End If End Sub Based On: http://www.shabdar.org/cross-thread-operation-not-valid.html

    Read the article

  • Display\Capture InnerException Message

    - by madlan
    I was using the following to provide more information on a common exception that can occour in a piece of my code, the only problem is this errors if an exception is generated that has no InnerException message. Catch ex As Exception 'MessageBox.Show(ex.Message) 'If there is no InnerException. MessageBox.Show(ex.InnerException.InnerException.Message) End Try Is there a better method of doing this?

    Read the article

  • Array basics - Populating with loop

    - by madlan
    Hi, I'm looping through a zip file trying to add the file name of each file within. Is this the correct method? Dim ZipNameArray(?) Using zip As ZipFile = ZipFile.Read(ZipToUnpack) For Each file In zip ZipNameArray(?) = file .FileName Next End Using I do not know the array size until I start looping through the zip (To work out the number of files within). How do I increment the Array? file is not a number? (It's a ZipEntry)

    Read the article

1