Visual Basic Recordsets and ListView Searching

Started by ShadowPierce, October 01, 2011, 01:36:42 pm

Previous topic - Next topic

ShadowPierce

->I'm a Computer Science major, currently the project leader for our Computer Programming 3 thesis... Despite being the project leader, I do all the work... So             I came here to ask for some Visual Basic help... No advanced stuff please, we're still on the basics so my professor would probably get suspicious if I use some weird code....

Anyway, could anyone take a look at this code? I can't, for the love of Blizzard, seem to make it run properly... It always catches a different error every time I try to change it, specifically the Sub on the Textbox:
Spoiler: ShowHide


Sub FillListView()
    ListView1.ListItems.Clear
    dbConnect
        rs.Open "Select * from tblProducts", db, 1, 2
        Do Until rs.EOF = True
            Dim lst As ListItem
            Set lst = ListView1.ListItems.Add(, , rs!pID)
            lst.SubItems(1) = rs!pName
            lst.SubItems(2) = rs!pCategory
            lst.SubItems(3) = rs!pSubCategory
            lst.SubItems(4) = rs!pColor
            lst.SubItems(5) = rs!pSize
            lst.SubItems(6) = rs!pSizeType
            lst.SubItems(7) = rs!pPrice
            lst.SubItems(8) = rs!pSupplier
            lst.SubItems(9) = rs!pInStock
            lst.SubItems(10) = rs!pReorderQty
            lst.SubItems(11) = rs!pMiscDetails
            rs.MoveNext
        Loop
        rs.Close
    dbDisconnect
End Sub

Private Sub Form_Load()
cboSearchBy.AddItem "Product Name"
cboSearchBy.AddItem "Category"
cboSearchBy.AddItem "Color"
cboSearchBy.AddItem "Size Type"
cboSearchBy.AddItem "Supplier"
cboSearchBy.Text = "Product Name"
FillListView
End Sub

Private Sub txtKeyword_Change()
ListView1.ListItems.Clear
    dbConnect
        rs.Open "Select * from tblProducts where " & cboSearchBy.Text & " like '" & txtKeyword.Text & "%'", db, 1, 2
        Do Until rs.EOF = True
            Dim lst As ListItem
            Set lst = ListView1.ListItems.Add(, , rs!pID)
            lst.SubItems(1) = rs!pName
            lst.SubItems(2) = rs!pCategory
            lst.SubItems(3) = rs!pSubCategory
            lst.SubItems(4) = rs!pColor
            lst.SubItems(5) = rs!pSize
            lst.SubItems(6) = rs!pSizeType
            lst.SubItems(7) = rs!pPrice
            lst.SubItems(8) = rs!pSupplier
            lst.SubItems(9) = rs!pInStock
            lst.SubItems(10) = rs!pReorderQty
            lst.SubItems(11) = rs!pMiscDetails
            rs.MoveNext
        Loop
        rs.Close
    dbDisconnect
End Sub


Answers ASAP please... Thanks! :haha:



Spoiler: ShowHide
Quote from: Blizzard on February 16, 2011, 03:44:48 pmThere you go. It's the proof that SDK is crap. It's incompatible with itself.
3DS Friend Code: ShowHide
1161-0627-9890

ForeverZer0

I would move this to Sea of Code, but for some strange reason Academics is like the one board I have no control of. I think Blizz is calling me stupid in some passive-aggressive type of way ;)

Unfortunately, Visual Basic is not my forte, so I am sorry that I cannot help a lot. I am unsure of the rules of VB, but I do know that most languages do not allow for modification of an Array/List during iteration. It appears that is what you are trying to do. What errors is it giving it you?

I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Ryex

October 01, 2011, 01:59:51 pm #2 Last Edit: October 01, 2011, 02:04:07 pm by Ryex
Well, I think your out of luck here man. I'm one of the few people here who has any experience with VB. in fact. I might be the only one. the only experience I have with VB is from back when I was helping JC with Pokemon Neon and he was writing a new engine in VB.

any way your using VB and MySQL if the SQL like query stings are any clue, and from my limited experience I see nothing wrong. I would help me to know what kind of errors you are getting or what isn't working, I could point you to potential problem sources then.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

ShadowPierce

->I think I'm getting there, instead of taking the field name from the database itself, I assign it on a string first before using it in the recordset...

I'm getting various kinds of errors every time I change the code on the textbox, but this is the most common:

Quote
Runtime error '-2147217 (80040e14)'

Syntax error (missing operator) in query expression.


Any ideas as to why this happens?  :hm:



Spoiler: ShowHide
Quote from: Blizzard on February 16, 2011, 03:44:48 pmThere you go. It's the proof that SDK is crap. It's incompatible with itself.
3DS Friend Code: ShowHide
1161-0627-9890

Ryex

this error is telling you that your SQL query is malformed. somewhere in your iteration the query is generated with a missing operator.
to debug it have it generate the query as a string and print it before using it to query the database. the last string to get printed before the error gets raised is the one that is malformed.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

ShadowPierce

->I tried redefining my queries but still no luck... :(



EDIT:
->Wait! Got it! It seems that my queries weren't matching with the string read by VB, so I just had to change those with my combobox so that they can work... Thanks Ryex! *hugs* :haha:

Resolved in less than an hour... :D



Spoiler: ShowHide
Quote from: Blizzard on February 16, 2011, 03:44:48 pmThere you go. It's the proof that SDK is crap. It's incompatible with itself.
3DS Friend Code: ShowHide
1161-0627-9890

Ryex

I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

G_G

Quote from: Ryex on October 01, 2011, 01:59:51 pm
Well, I think your out of luck here man. I'm one of the few people here who has any experience with VB. in fact. I might be the only one. the only experience I have with VB is from back when I was helping JC with Pokemon Neon and he was writing a new engine in VB.

any way your using VB and MySQL if the SQL like query stings are any clue, and from my limited experience I see nothing wrong. I would help me to know what kind of errors you are getting or what isn't working, I could point you to potential problem sources then.


You wish! >:U The very first version of Cybele was coded in VB. In fact, I learned Visual Basic before C#. *goes back to doing chores because no one around this house has to do them ever*

ForeverZer0

Quote from: Ryex on October 01, 2011, 01:59:51 pm
Well, I think your out of luck here man. I'm one of the few people here who has any experience with VB. in fact. I might be the only one. the only experience I have with VB is from back when I was helping JC with Pokemon Neon and he was writing a new engine in VB.


He never said he was the only one. Just saying. :V:
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

G_G

Quote from: Ryex on October 01, 2011, 01:59:51 pm
Well, I think your out of luck here man. I'm one of the few people here who has any experience with VB. in fact. I might be the only one. the only experience I have with VB is from back when I was helping JC with Pokemon Neon and he was writing a new engine in VB.



Ryex

Quote from: Ryex on October 01, 2011, 01:59:51 pm
Well, I think your out of luck here man. I'm one of the few people here who has any experience with VB. in fact. I might be the only one. the only experience I have with VB is from back when I was helping JC with Pokemon Neon and he was writing a new engine in VB.


well that makes TWO people who know VB.

also when I was first looking at the code and asked for the error, I had a feeling that the error would be with the SQL and not the actual VB.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

ForeverZer0

I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

Quote from: ForeverZer0 on October 01, 2011, 05:54:51 pm
lol

Zer0 = fail


But doesn't this mean you're not failing at all, because it's zero fail?

Spoiler: ShowHide
:troll:
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

ForeverZer0

That means I am incapable of failure.

I like your reasoning.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

winkio

You are incapable of being incapable.  Reasoning is broken.

ForeverZer0

Being incapable does not necessarily mean failure, so win. :V:
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

ShadowPierce

->Anyone willing to take a look at the system I did so far? It's still unfinished & missing a lot of things (will be passing it in 3 days) so please post bugs & errors here... :haha:

http://www.mediafire.com/?ts2wp12s91oq99k

NOTE: Requires VB and MS Access to open all files

I'd really appreciate it if you guys would help! ;)



Spoiler: ShowHide
Quote from: Blizzard on February 16, 2011, 03:44:48 pmThere you go. It's the proof that SDK is crap. It's incompatible with itself.
3DS Friend Code: ShowHide
1161-0627-9890

Ryex

I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

ShadowPierce

->Nothing, really... I just can't find a bug so I thought I'd ask someone to "beta-test" it in case I missed something... :P



Spoiler: ShowHide
Quote from: Blizzard on February 16, 2011, 03:44:48 pmThere you go. It's the proof that SDK is crap. It's incompatible with itself.
3DS Friend Code: ShowHide
1161-0627-9890

Ryex

ah, makes sense. others can often find bugs you thought were impossible until they manifested themselves.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />