|
Is it possible to sort by two columns in a listview? Can someone send me a link or sample?
I have a list view that has 4 columns;
Class Code, Class Description, Category Code, Category Description.
Right now it sorts the class code ascending but I want it to sort first by class/category code.
All samples I find that use IComparer are only sorting by a single column.
Thanks,
digicd1
|
|
|
|
|
The control does not support it, I suspect you need to sort your data source and then bind to it, sorted. Or write code to shuffle items yourself.
Oh - what if you just sort by your secondary key, then your primary key ? Wouldn't that work ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
|
Maybe you could use a dataview and sort/filter your datasource, then get the rows from the sorted/filtered dataview and add them to the listview
Alexei Rodriguez
|
|
|
|
|
I've encountered a messy bug that requires that I use Jet 2.x code rather than Jet 4.0 code that causes the problem.
Here's the situation:
I have to deal with a legacy multi-user application that runs Access 2.0. I need to change some of the Access 2.0 tables from my vb.net application. When I use OLEDB (or even ODBC) and the 4.0 Jet provider the following circumstances happen:
Let's say 2 people are running the legacy Access 2.0 application with the .mdb table I need open (which is the usual running state). The .ldb file for this shows the normal computer name strings and User (admin) in single byte per character format. I open the database with the Jet 4.0 driver in vb.net. All is still well, it adds my computer name and user as the third record in the .ldb file. Now, I close the database from vb.net. Jet 4.0 rewrites the .ldb file to show that it is no longer connected, and that the two legacy apps still are -- EXCEPT -- it writes the .ldb file in two byte per character format, which the legacy Access 2.0 apps don't understand. What ends up happening is that the legacy apps continue to run, but I can't start up another legacy app because the .ldb file is "updated," and, if I quit a legacy app, I can't restart it unless I've quit all the legacy apps (thus deleting the .ldb file).
What I need is to have a driver that will rewrite the .ldb file in the legacy format when there are legacy apps using the .ldb file at the same time (i.e. 1 byte per character). VB6 driver would do this, but the new Jet 4.0 driver does the above behavior. I've seen some references to dll's that emulate the old behavior, but I don't know how to put them in place of the 4.0 driver (I see no other providers than the 4.0 driver). Anybody have any ideas?
-Owen
P.S. Yes, I have to use Access 2.0, until they update it to SQL server later this year. The bitch is that it worked with VB6, and now the new update to .NET kills it.
-O
|
|
|
|
|
Wow. Didn't know anyone still used Access 2.0
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
owen hartnett wrote: Yes, I have to use Access 2.0, until they update it to SQL server later this year.
Thankfully, there's only 4 months left.
owen hartnett wrote: The bitch is that it worked with VB6, and now the new update to .NET kills it.
That's because the .NET Framework requires an updated MDAC be installed, which updates Jet to 4.0. No, the components do not reside on the machine side-by-side. As far as I know, you're S.O.L trying to use a .NET solution for such an old database.
|
|
|
|
|
I've actually solved *some* of my issues, but the major one remains.
First of all, I can send "JET OLEDB:Engine Type=1" in the connection string, and the JET engine won't default to double byte on close.
However, when I close the Jet connection, it puts a "delete pending" on the .ldb file, effectively shutting it down for further connections until everybody quits the .mdb file and the .ldb is destroyed.
Here's the scenario:
Open an access database in Access 2.0 shared simultaneously on 2 workstations.
Open an ADO connection in VS 2005 to the same database (you can even make the mode "read" and it still happens)
Close the ADO connection. This is where all hell breaks loose. ADO puts a "Delete Pending" on the file (according to FileMon). The two Access 2.0 can continue to use the database, but VS 2005 can no longer open it, and no further Access 2.0 workstations can open it. If either of the two Access databases quits, then it's locked out until all the other ones connected at the time quits.
It looks like a bug in the .dll that drives Jet 2.0 access through the Jet 4.0 provider. I tried ODBC, but that seemed to have the same problem, and there wasn't a way I could specify previous JET versions through ODBC.
So, I'm again at a loss. Anybody have any clues on how to stop this "DELETE PEND?"
-Owen
|
|
|
|
|
How can we resize and move a label control in all directions in dot.net environment at runtime on a windows form.
|
|
|
|
|
Size and location properties? Not sure what you're confused on here..
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
to auto resize a label you have to set AutoSize property to true.
to move ?
you mean to move with mouse ?
google it you can find many solutions.
|
|
|
|
|
|
I need to create a window service which can track or log the web sites i have visited. Can anyone help? It's urgent
|
|
|
|
|
Ahh, the urgent questions. If you want it to work with all browsers you'll have to go the sniffer route. There's plenty on Google about getting IE's current URL so I won't go into that.
|
|
|
|
|
You can either write your own Proxy server, or use one off-the-shelf.
|
|
|
|
|
hi all,
iam creating table for display data dynamically using asp.net with vb.net 2.0
here is problem is that iam linkbutton not added to table cell .
can any body help me that where iam doing mistake here is my code .
Dim noOfTimes As Integer = 0
Dim CurrentName As String = Nothing
Dim trow As TableRow = New TableRow
For d = 0 To 31
Dim tbcell As TableCell = New TableCell
'Iterate to see which cells have a booking against a name
If testarray(d) = Nothing Then
'No booking case
CurrentName = Nothing
tbcell.BackColor = Color.FromName("#FFFFFF")
Else
'booking exists, find noOfTimes it is booked for same employee
CurrentName = testarray(d)
'search subsequent entries for same name
Dim j As Integer
For j = d + 1 To 31
'
If testarray(j) = CurrentName Then
'same name repeated
noOfTimes = noOfTimes + 1
Else
'name is not repeated, print name and advance d counter by number of times
Response.Write(" Span of " + noOfTimes.ToString() + " " + CurrentName)
d = d + noOfTimes
'exit for loop using the statement below
Exit For
End If
Next
Dim myHyperLink1 As LinkButton = New LinkButton()
myHyperLink1.ID = "myHyperLink1"
myHyperLink1.Text = "Click Here dear "
myHyperLink1.PostBackUrl = ""
AddHandler myHyperLink1.Click, AddressOf OnClickLink
' tbcell.BackColor = Color.FromName("#CCCCCC")
tbcell.ColumnSpan = noOfTimes
tbcell.Controls.Add(myHyperLink1)
noOfTimes = 0
End If
tbcell.Text = " "
trow.Cells.Add(tbcell)
Next
Table1.Rows.Add(trow)
please suggest me where iam doing mistake where i have to added linkbutton creation code ?
best regards
Rameez
thanks in advance
|
|
|
|
|
|
Hello,
Maybe a stupid question.
When i read from my database is do for example myreader.getstring(15) when i do this i read out the colom 15 that is in the record.
My coloms are bigger than 20 so now i have the problem when i try to Read for ex. Myreader.getstring (21) that the matri is not big enough.
Can anyone tell me how i can read out bigger than 20. Maybe change the dim but i dont know where.
My read programm for example :
Dim cnstandaardinstellingen As New SqlConnection(connectionstring)
Dim cmdstandaardinstellingen As New SqlCommand
cnstandaardinstellingen.Open()
Dim strQuerystandaardinstellingen As String = "select * from instellingen where hotel ='" + hotel + "'"
Dim myCommandstandaardinstellingen As New SqlCommand(strQuerystandaardinstellingen, cnstandaardinstellingen)
Dim myReaderstandaardinstellingen As SqlDataReader = myCommandstandaardinstellingen.ExecuteReader()
myReaderstandaardinstellingen.Read()
ticketprinterport = myReaderstandaardinstellingen.GetString(12)
Startgroup = myReaderstandaardinstellingen.GetString(21) --> here there is a error that the Matrix is not big enough.
myReaderstandaardinstellingen.Close()
cnstandaardinstellingen.Close()
Thanks.
DCA
|
|
|
|
|
DCAUB wrote: When i read from my database is do for example myreader.getstring(15) when i do this i read out the colom 15 that is in the record.
The columns are zero indexed, so myReader.GetString(15) will return the 16th column.
DCAUB wrote: here there is a error that the Matrix is not big enough.
That does not sound like any error message I recognise. Please copy and paste the actual error message.
DCAUB wrote: select *
This is bad practice. You should always list the column names, that means that if the database changes your program will still work. (Unless the column has been removed)
DCAUB wrote: where hotel ='" + hotel + "'"
This is also bad practice, your code is susceptable to a SQL Injection attack. You should at the very least use parameterised queries to protect yourself.
|
|
|
|
|
Hello,
Thanks for answering my question.
I have found the problem. There Where 21 colomns, my mistake forgotten to count from 0 but i started from 1 so there was no 21 colomn.
Can you please give me a small example how i can optimize my SQL commands. for example where hotel ='" + hotel + "'"
Thanks for helping me further.
Best regards
DCA
|
|
|
|
|
DCAUB wrote: Can you please give me a small example how i can optimize my SQL commands
See this article on SQL Injection Attacks[^] and read the section on Parameterised Queries. In fact, you should read the whole thing in order to fully protect yourself.
|
|
|
|
|
I checked in msdn forum as well but there is one thread still pending not getting the answer of the similar problem, so I thought of posting it here.
Lets get the picture of the problem first.
1. I have a form called cat where I have one field called CatName where I save the data.
2 I have another form where I have got Combo box where I load cats when form loads.
Now question is imagine I have more than 40 fields in the form 2 where user filled up 39 fields but when he came to cats combo box then he found that one cat is not there so he opens cat form to add the new cat in it.
Then how can i acheive this without opening a new form.
Here is what i have tried so far
this is the sub where i load cats in combobox:
Public Sub LoadCats(ByVal cboCats As ComboBox)
Dim objdb As New clsObjDB
Dim ds As New DataSet
Dim str As String
cboCats.Items.Clear()
str = "Select * from cat order by catID desc"
ds = objdb.getDataset(str)
Dim dt As DataTable
dt = ds.Tables(0)
For Each row As DataRow In dt.Rows
cboCats.ValueMember = row("CatID")
cboCats.Items.Add(row("CatName"))
Next
End Sub
Now in cat I tried
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
Dim objdb As New clsObjDB
Dim str As String
If txtCatName.Text.Trim = "" Then
MessageBox.Show("Enter the Cat Name")
txtCatName.Focus()
objdb = Nothing
Exit Sub
End If
str = "Insert into cat(CatName)values('" & txtCatName.Text & "')"
objdb.ExecuteQuery(str)
MessageBox.Show("Success")
'*****************************************
'Now my save is finished so over here i tried loading of cbocats
Dim frm As dog
'********* Here is the problem I can't do new here because the user wants to stay on the same page he was working on.
LoadCats(frm.cboCats)
Me.txtCatName.Text = ""
End Sub
Hope you guys get the point, I am very poor in explaining these sort of things....
Thanks in advance
|
|
|
|
|
rprateek wrote: Dim dt As DataTable
dt = ds.Tables(0)
For Each row As DataRow In dt.Rows
cboCats.ValueMember = row("CatID")
cboCats.Items.Add(row("CatName"))
Next
Instead of adding each cat to combobox
Why dont you set datasource, displaymember and valuemember?
If you are using a different form to add, update and delete from your cats catalog, just call that form from your cat form (as you are doing now) using showdialog and after that, just call your loadcats again to refill combobox
I didnt really understand what you are doing, but this should work
Alexei Rodriguez
|
|
|
|
|
ya i understand your point but i didn't mean that..
you can try it yourself I just want is one form for eg form1 open where we have cbobox where we have cats.
now as per your advice i did datasource and data member .
ok i opened the dialog box to insert new cat.
Now how would you load the cats in the same form called form1 that is open.
where you have to do following to load cats
LoadCats(frm.cboCats)
but if you don't do frm= new frmCats then it will show error ..... so how to overcome this.?????????
|
|
|
|
|
hey guys please have a look into this
|
|
|
|