|
Hi Dave,
thanks for your reply. I'm working with ADO-classes and i fill my datatable (ADO-class) with data from my database. I use the "ORDER BY"-statement in my SQL-string to fill my datatable in the needed order. But at one specific part i need to change the order.
For example, i fill my datatable via a tableadapter (also ADO-class) with the SQL-Statement
SELECT * FROM myDB ORDER BY a, b DESC
Then, the data are stored in my datatable in exact the order given by the statement. I go through my datatable an do some calculations with my records. When i reach - lets say - record No.30, i want to change the order of the next 10 records. After the 10 records, the order should remain the same as before.
I hope you could understand it better now.
|
|
|
|
|
If I understand you correctly you
Want to modify your a subsection of your datatable with a new order which still sits within the same datatable?
If I have this correct then as far as I am aware there is no existing method that can do this other than making yourself a routine to rebuild the datatable in the order that you want
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Well, You'd have to build your own DataView from the data in the DataTable object, adding the records you need in the order you need them. You will have to implement your own sorting algorithm to do this.
In your example, you'd have to add records 0 through 29, then create a collection of records 30 through 40, send that to be sorted, then add those sorted records to the view, then add the remaining records.
|
|
|
|
|
Hello everybody and thanks for your replies,
i could manage to solve the problem with the algorithm presented in my first post. Here is my solution for those, who are interested in it:
iBlockRowStart = iCurrentRow
iBlockRowStop = iBlockRowStart
Do While System.Convert.ToDateTime(DS.Tables("AnyTable").Rows(iBlockRowStop).Item("Date")).DayOfWeek = dayofweek.Friday
iBlockRowStop = iBlockRowStop + 1
If iBlockRowStop = DS.Tables("AnyTable").Rows.Count Then
Exit Do
End If
Loop
iBlockRowStop = iBlockRowStop - 1
tempTable = DS.Tables("AnyTable").Clone()
For j = iBlockRowStart To iBlockRowStop
tempTable.ImportRow(DS.Tables("AnyTable").Rows(j))
Next
View = tempTable.DefaultView
View.Sort = "ColA, ColB"
Dim tempTable2 as DataTable = View.ToTable()
For j = iBlockRowStart To iBlockRowStop
For k = 0 To tempTable2.Columns.Count - 1
DS.Tables("AnyTable").Rows(j).Item(k) = tempTable2.Rows(j - iBlockRowStart).Item(k)
Next
Next
With this piece of code it is possible to sort a part of a datatable in a dataset in another order. In my case, i needed this repeatedly when the date of my record was friday. I needed to sort my "friday-records" in another order. My datatable was filled with data of a month, so i had four fridays...
Thanks again for your help!
|
|
|
|
|
Not sure I understand you, however if the sort I get wouldn't do what I want I would:
1.
either: provide a better comparer (implement ICompare, which is very easy) and have the built-in Sort use that;
here[^] is a little article on the subject.
2.
or: add a column (possibly never to be shown), make sure its cells get numbered in the order I want, then sort on that column.
|
|
|
|
|
Hi please help
How can i add the reference to my windows form here is my references
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls---here is giving me an error
Imports System.Net
Imports System.Configuration
Imports System.Text.RegularExpressions
Imports System.IO
Imports System.Text
Imports System.Web.UI.HtmlControls----here is giving me errors again...
I am sending an sms from windows form...
|
|
|
|
|
If all you're doing is send an SMS you don't need the references to System.Web.UI and System.Web.UI.WebControls, nor System.Web.UI.HtmlControls, unless, of course, you're writing an ASP.NET application and not a Windows Forms app.
|
|
|
|
|
Minenhle Ndlovu wrote: here is giving me an error
and I bet the error message is telling you exactly what is wrong.
BTW: if you don't understand the error message, it would still be wise to post it so others who do can help.
|
|
|
|
|
You need to add a reference to the system.web .net library in your application
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Minenhle Ndlovu wrote: How can i add the reference to my windows form here is my references
Those are imports; it says what is being imported in that unit, from all the references that are available in your project.
Are you using Visual Studio? If so, go to the "Project" menu and choose "Add reference" from there. Both SharpDevelop and MonoDevelop have a similar options. If you're using a text-editor, you'll have to edit the project by hand.
Bastard Programmer from Hell
|
|
|
|
|
Hi all,
In access, we can print multiple report in a single button, how
to do that in asp.net? I'm using report viewer.
I really appreciate who can gave me a detailed solution. I ask already google.
Thanks in advance!
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
Hey.Frnds...I want to know how to create my own Spammer wid Vbscript....Plz Give me answer of this..Plz describe wid Basics frnds...
|
|
|
|
|
|
Certainly.
All you need to do is get some education, a decent job and a sexual partner.
Then you won't need to be a complete arse.
It is the sort of thing that morons and losers do, and it shows you are someone in need of a life.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
It's an OO world.
public class Naerling : Lazy<Person>{}
|
|
|
|
|
I do like the subtleties in your use of language.
|
|
|
|
|
Your asking a bunch of people who HATE spam with a passion how to write something that send that stuff out?? And you call us "friends"??
|
|
|
|
|
Thanks for the laugh. It's a rough Monday morning, and I needed it.
|
|
|
|
|
Hello All,
I'm playing with interactions between excel and vb.net...
Everytime i start an excel application it become's one of my processes in my taskbar.
I always put my vars from workbook,sheets,app to nothing at the end
i collect my garbage
But wath do i forget to dispose this from the services??
I'm kind a noob so can somebody provide me some help?
I just want to clean up after using...
oSheet = Nothing
oBook = Nothing
oExcel.Quit()
oExcel = Nothing
GC.Collect()
Thx in advance
|
|
|
|
|
|
Hey,
Thx Dave it was a really helpfull article.
Can you check if i forget something?(maybe in my catch blok or something?)
Dim oApp As New Excel.Application()
Dim oBook As Excel.Workbook = oApp.Workbooks.Add
Dim oSheet As Excel.Worksheet = oApp.ActiveSheet
Dim chartRange As Excel.Range
'hoofding
chartRange = oSheet.Range("A1", "I1")
chartRange.Merge()
chartRange.FormulaR1C1 = "WorkBook"
chartRange.Font.Bold = True
chartRange.Font.Size = 20
chartRange.HorizontalAlignment = 3
'chartRange.VerticalAlignment = 3
'Save the Workbook
oBook.SaveAs(sSampleFolder & "V.F." & idvoorexcel & "-" & Label6.Text & ".xlsx")
oSheet = Nothing
oBook.Close(False)
oBook = Nothing
oApp.Quit()
oApp = Nothing
System.Threading.Thread.Sleep(3000)
End If
Catch ex As Exception
MsgBox("location : catch blok")
oSheet = Nothing
oBook = Nothing
End Try
Greetings
|
|
|
|
|
Yeah, I see no mention of Marshal.ReleaseComObject() .
You might want to go back and re-read the article.
|
|
|
|
|
Hey i'm back from a student holiday
Thx for all the answers i will vote 4 them...
I posted the wrong code snippet
here is the code that i wanted to post :
Imports Microsoft.Office.Interop
Try
Dim oApp As New Excel.Application()
Dim oBook As Excel.Workbook = oApp.Workbooks.Add
Dim oSheet As Excel.Worksheet = oApp.ActiveSheet
chartRange = oSheet.range("A20", "G20")
oSheet.Range("A20").Value = "blabla"
chartRange.BorderAround(Excel.XlLineStyle.xlContinuous, _
Excel.XlBorderWeight.xlMedium, Excel.XlColorIndex. _
xlColorIndexAutomatic, Excel.XlColorIndex.xlColorIndexAutomatic)
'Save the Workbook and quit Excel.
oBook.SaveAs(sSampleFolder & "V.F." & idvoorexcel & "-" & Label6.Text & "-" & DateTime.Now.ToString("ddMMyyHHmmss") & ".xlsx")
oSheet = Nothing
NAR(oSheet)
oBook.Close(False)
NAR(oBook)
oBook = Nothing
oApp.Quit()
NAR(oApp)
oApp = Nothing
System.Threading.Thread.Sleep(1500)
End If
Catch ex As Exception
NAR(oSheet)
oBook.Close(False)
NAR(oBook)
oSheet = Nothing
oBook.Close(False)
oBook = Nothing
System.Threading.Thread.Sleep(1500)
GC.Collect()
End Try
Private Sub NAR(ByVal o As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(o)
Catch
Finally
o = Nothing
End Try
End Sub
By the way nice link with the NAR
Still don't know if i oversaw something?
Thx D
|
|
|
|
|
Hi,
I want to make one application that reads the pdf file and write that data in to excel sheet and after i have to make a chart in excel sheet.
Here, my problem is ,i do not know how to read the pdf file in VB .Please kindly help me by giving some solution or is there any tutorial or article related to this concern.
Anu
|
|
|
|
|
Anu_Bala wrote: any tutorial or article related to this concern.
Yes plenty[^].
|
|
|
|