Need help in vb coding

archish

Skilled
I am writing a simple stock verification program in vb with oracle backend. I need to get the stock details from the user and need to check if the required qty is available in the stock. If its there then I can place the order. I have made the connection to the database and written the query part. now i need to check if the required qty is available and if ok then when the order button is clicked i need to subtract the ordered qty and update the database, I am unable to complete the updation part. If anyone can help me out here it will be nice :)

PS: Attached the code
 

Attachments

  • Inventory System.zip
    2.6 KB · Views: 166
archish said:
I am writing a simple stock verification program in vb with oracle backend. I need to get the stock details from the user and need to check if the required qty is available in the stock. If its there then I can place the order. I have made the connection to the database and written the query part. now i need to check if the required qty is available and if ok then when the order button is clicked i need to subtract the ordered qty and update the database, I am unable to complete the updation part. If anyone can help me out here it will be nice :)
PS: Attached the code

Its simple.

Bind the data from the db to a textbox or label thats hidden from view, locked and has no tab stop. Next, compare the data retrieved from the db into the textbox or label by using the .text or .caption properties and either extract to other variables or directly perform operations to it.
Besides, i would like to make another suggestion. Use a standard code module for defining ur .connection and .recordset objects. Also, provide the connection string in this perticular module.
I would also like to suggest the use of data environment if u are using VB6.0.

Alternatively, Try to use coding format as follows if DE doesnt solve ur problem or u donot wish to use DE.

code said:
option explicit

.......

Dim db As ADODB.Connection

Dim adors As ADODB.Recordset

.......
'inside ur function/event

.......

Set db = New ADODB.Connection

'INSTANTIATE THE ADODB.CONNECTION OBJECT
db.Open "Provider=MSDAORA.1;", "scott", "tiger"

'OPEN THE CONNECTION

'DATA SOURCE= Leave Blank for Local Connection or provide a Connection string if on a network

'PROVIDER=MSDAORA(MICROSOFT ODBC DRIVERS FOR ORACLE)

'USERNAME=scott

'PASSWORD=tiger
Set adors = New ADODB.Recordset
adors.Open "UPDATE .....(Query statement goes here) where (condition)", db, adOpenDynamic, adLockOptimistic
You can use the above for retrieval of info from databast also by using the select query and changing the cursor and lock types etc.

Do experiment around a bit with this.
Hope this helps.

Do let me know.
 
Yeah, updation is always a pain, if u do not bind it to some text field.
Once I tried everything, and it just wouldn't work without some binding. So I put it in the data field of a label, and then hid the label. Hee Hee.
 
I forgot to mention one thing....incase u didnt know it...
Here is an example of a query.....
adors.Open "UPDATE user SET user_passwd='" & txtNewPasswd.Text & "' WHERE usr_id=" & usrid, db, adOpenDynamic, adLockOptimistic

please note: user is a dummy table in oracle, user_passwd and usr_id are fields and usrid is a variable which stores the entered userid txtNewPasswd is a text box containing the contents entered by the user.
All this is inside the event of click of a command button.
 
Back
Top