| | |
Do until loop
![]() |
•
•
Join Date: Jun 2009
Posts: 21
Reputation:
Solved Threads: 0
Good Day People
Please help me, I'm trying to do a do until loop, which can search the database to match the value that is entered in the vb6.0 textbox. but I don't know what to call the value in the database.
It looks something like this.
dim productid as integer
productid=me.productid.text
Do until productid=product_id(this is the value I don't know what to call, it is the value in the database)
PLEASE HELP.
Please help me, I'm trying to do a do until loop, which can search the database to match the value that is entered in the vb6.0 textbox. but I don't know what to call the value in the database.
It looks something like this.
dim productid as integer
productid=me.productid.text
Do until productid=product_id(this is the value I don't know what to call, it is the value in the database)
PLEASE HELP.
hi, this might give you an idea:
and just curious why you need me on this code;
why not do like this:
productid=productid.text
i hope it helps..
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
num = 1 ' initialize counter 'rs is the reference to your recordset change if needed Do While Not rs.EOF ' See if the data has been found If product_id = rs!product_id Then 'do something here End If ' If not found move to the next record. num = num + 1 rs.MoveNext Loop
and just curious why you need me on this code;
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
dim productid as integer productid=me.productid.text
productid=productid.text
i hope it helps..
•
•
Join Date: Dec 2007
Posts: 252
Reputation:
Solved Threads: 27
if it is a specific item you are looking for why search through mulitple records?
then you can run your do while.
vb Syntax (Toggle Plain Text)
sSQL = "Select fields from table where id = " & productid & "
then you can run your do while.
Last edited by ProfessorPC; Jul 30th, 2009 at 8:24 pm.
•
•
Join Date: Jun 2009
Posts: 21
Reputation:
Solved Threads: 0
•
•
•
•
hi, this might give you an idea:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
num = 1 ' initialize counter 'rs is the reference to your recordset change if needed Do While Not rs.EOF ' See if the data has been found If product_id = rs!product_id Then 'do something here End If ' If not found move to the next record. num = num + 1 rs.MoveNext Loop
and just curious why you need me on this code;
why not do like this:Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
dim productid as integer productid=me.productid.text
productid=productid.text
i hope it helps..
But it still won't work have been at it, trying to find the problem but to no avail, is it not possible to reference a variable in VB6.0 to a variable in oracle database. Because thats all I need.
Do until productid(vb6.0)=productid(database)-this is the problem
if productid(vb6.0)=productid(database) then
do something
loop
end if
•
•
Join Date: Dec 2007
Posts: 252
Reputation:
Solved Threads: 27
what are you using to connect to the DB? i am guessing something like this:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Set cn = New ADODB.Connection cn.Open 'connection string Set rs = New ADODB.Recordset rs.Open "Select fields from table where id = " & productid.text & "", cn While Not rs.EOF do something rs.MoveNext rs.Close Set rs = Nothing cn.Close Set cn = Nothing
Last edited by ProfessorPC; Aug 13th, 2009 at 10:02 am.
•
•
Join Date: Jun 2009
Posts: 21
Reputation:
Solved Threads: 0
•
•
•
•
what are you using to connect to the DB? i am guessing something like this:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Set cn = New ADODB.Connection cn.Open 'connection string Set rs = New ADODB.Recordset rs.Open "Select fields from table where id = " & productid.text & "", cn While Not rs.EOF do something rs.MoveNext rs.Close Set rs = Nothing cn.Close Set cn = Nothing
I think it works, but won't see that properly now because it gives an error later on when I say: if productid=rs!product_id then
rs.open"select fields from table", "update field set data"
but it gives me an error on open(wrong number of arguments or invalid property assignment), could you please help, i have also tried .execute instead of .open, but it gives me the same error message.
Please help!!!!
•
•
•
•
Thanks For your help, Proffessor PC.
I think it works, but won't see that properly now because it gives an error later on when I say: if productid=rs!product_id then
rs.open"select fields from table", "update field set data"
but it gives me an error on open(wrong number of arguments or invalid property assignment), could you please help, i have also tried .execute instead of .open, but it gives me the same error message.
Please help!!!!
Last edited by cguan_77; Aug 15th, 2009 at 3:30 am.
•
•
Join Date: Jun 2009
Posts: 21
Reputation:
Solved Threads: 0
•
•
•
•
hi mpande, the code that Proffessor PC gives you it seems to work fine.. so maybe you can post the code that you try
If productid = rs!product_id Then
Set updatedb = New ADODB.Connection
updatedb.Open "DSN=waterdb;Password=andile;User ID=eco;Data Source=waterdb"
Set rs1 = New ADODB.Recordset
rs1.Open "Select product_id,qty,stock_date,trans_type,qtydb from stock", "update stock set product_id=productid", "update stock set qty=qty", "update stock set stock_date=date", "update stock set trans_type=trans_type", "update stock set qtydb=qtydb"
With Adodc1
.Recordset.Update
.Recordset.Fields("product_id") = productid
.Recordset.Fields("qty") = qty
.Recordset.Fields("stock_date") = dop
.Recordset.Fields("trans_type") = "trans_type"
.Recordset.Fields("qtydb") = qtydb
End With
Else: MsgBox ("invalid product id")
End If
db.CommitTrans
rs.MoveNext
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
Loop
But the problem is at rsi.open, it gives me an error saying-wrong number of arguments or invalid property assignment.
Please help!!
•
•
Join Date: Dec 2007
Posts: 252
Reputation:
Solved Threads: 27
•
•
•
•
Hi cguan the code that I'm using is this:
If productid = rs!product_id Then
Set updatedb = New ADODB.Connection
updatedb.Open "DSN=waterdb;Password=andile;User ID=eco;Data Source=waterdb"
Set rs1 = New ADODB.Recordset
rs1.Open "Select product_id,qty,stock_date,trans_type,qtydb from stock", "update stock set product_id=productid", "update stock set qty=qty", "update stock set stock_date=date", "update stock set trans_type=trans_type", "update stock set qtydb=qtydb"
With Adodc1
.Recordset.Update
.Recordset.Fields("product_id") = productid
.Recordset.Fields("qty") = qty
.Recordset.Fields("stock_date") = dop
.Recordset.Fields("trans_type") = "trans_type"
.Recordset.Fields("qtydb") = qtydb
End With
Else: MsgBox ("invalid product id")
End If
db.CommitTrans
rs.MoveNext
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
Loop
But the problem is at rsi.open, it gives me an error saying-wrong number of arguments or invalid property assignment.
Please help!!
lol. so you get the data from the product id. you are updating the table with the values in txt boxes? if that is the way your are working it lets try this. Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
rs1.Open "UPDATE Stock (qty, stock_date, trans_type, qtydb ) Values (" & qtyfield &", " & stock_datefield &", " & trans_type &", " & qtydbfield &")", updatedb
been a long day hope that works lol
![]() |
Similar Threads
- Help with gui loop. (C)
- Loop...without the loop (Java)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Pyramid Issue
- Next Thread: cells.find in excel
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






