Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
iftikhar
Starting Member
3 Posts |
Posted - 2011-05-01 : 11:49:10
|
Dear experts,I have this following sql query which is working fine. however, I would like to add a sort feature (order by TitleName)to the following sql query. Thanks in advance for your time.Private Sub List2_Click()On Error Resume NextDim conn As New ADODB.ConnectionDim rs As New ADODB.RecordsetDim rs2 As New ADODB.Recordset 'conn.Open "dsn=cool"conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\control\sys\exercise.binar" conn.OpenList3.ClearintType = list2.ItemData(list2.ListIndex)Set rs = conn.Execute("select product.TitleName, product.txtSentence, product.category, Product.prodid, category.id from product Inner Join category on product.category = category.id where category.id = " & intType)'List3.RightToLeft = TrueDo Until rs.EOFList3.AddItem rs("txtSentence")List3.ItemData(List3.NewIndex) = rs("prodid")rs.MoveNextLooptxtVocabCat.Text = intTypers.Close'---List3.ListIndex = 0'''====================End Sub-------------------------------------------------------I tried the following but does NOT work:Set rs = conn.Execute("select product.TitleName, product.txtSentence, product.category, Product.prodid, category.id from product Inner Join category on product.category = category.id where category.id = " & intType) order by titleName ASC |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-05-01 : 11:53:08
|
Set rs = conn.Execute("select product.TitleName, product.txtSentence, product.category, Product.prodid, category.id from product Inner Join category on product.category = category.id where category.id = " & intType & " order by product.TitleName")Woud be easier to put this in a stored proceure with category.id as a parameter.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
iftikhar
Starting Member
3 Posts |
Posted - 2011-05-01 : 11:57:09
|
Thanks nigelrivettLet me try now and be back. |
|
|
iftikhar
Starting Member
3 Posts |
Posted - 2011-05-01 : 12:03:10
|
Perfect!Thanks so much nigelrivett. I can not appreciate you enough for it. I was struggling with it for few hours. May Allah bless you in both the worlds. |
|
|
|
|
|
|
|