RSS Forums RSS

About Updating a Record in adodb

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Reply
Posts: 161
Reputation: ryan311 has a little shameless behaviour in the past 
Solved Threads: 1
ryan311 ryan311 is offline Offline
Junior Poster

About Updating a Record in adodb

  #1  
Dec 1st, 2008
Private Sub Command1_Click()
If Combo1.Text = "" Then
MsgBox "Please Choose Supplier Code", vbInformation
Combo1.SetFocus
Exit Sub
End If
If Combo2.Text = "" Then
MsgBox "Please Choose Product Code", vbInformation
Combo2.SetFocus
Exit Sub
End If
If Text1.Text = "" Then
MsgBox "Please Input the Quantity", vbInformation
Text1.SetFocus
Exit Sub
End If
If Text3.Text = "" Then
MsgBox "Please Input the Amount", vbInformation
Text3.SetFocus
Exit Sub
End If
rs.Open "Insert Into Deliver (scode, pcode, quantity, unit, amount, pcarrier, pterms, drnumber, date) Values ('" + Combo1.Text + "','" + Combo2.Text + "','" + Text1.Text + "','" + Text2.Text + "','" + Text3.Text + "','" + Text4.Text + "','" + Text5.Text + "','" + Text6.Text + "','" + Text7.Text + "')", cn, adOpenKeyset, adLockPessimistic
Set rs = Nothing
rs1.Open "select * from Product where pcode='" & Combo2.Text & "'", cn, adOpenKeyset, adLockPessimistic
If rs1.RecordCount > 0 Then
rs1.Fields![pstock] = Val(rs1.Fields![pstock]) + Val(Text1.Text)
rs1.Update
rs.Close
MsgBox "The Product has been save successfully", vbInformation
Combo1.Text = ""
Combo2.Text = ""
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Call Form_Load
Else
MsgBox "OHH NO!", vbInformation
End If
End Sub

i have a problem everytime i click my command1 button can anyone help me about my problem? please? badly needed rush! please help me god bless daniweb!


error is on about in INSERT INTO
Last edited by ryan311 : Dec 1st, 2008 at 6:45 am. Reason: i forgot something
AddThis Social Bookmark Button
Reply With Quote  
Posts: 293
Reputation: aktharshaik is an unknown quantity at this point 
Solved Threads: 35
aktharshaik's Avatar
aktharshaik aktharshaik is offline Offline
Posting Whiz in Training

Re: About Updating a Record in adodb

  #2  
Dec 1st, 2008
Corrections
rs.Open "Insert Into Deliver (scode, pcode, quantity, unit, amount, pcarrier, pterms, drnumber, date) Values ('" + Combo1.Text + "','" + Combo2.Text + "','" + Text1.Text + "','" + Text2.Text + "','" + Text3.Text + "','" + Text4.Text + "','" + Text5.Text + "','" + Text6.Text + "','" + Text7.Text + "')", cn, adOpenKeyset, adLockPessimistic 

must be
cn.Execute "Insert Into Deliver (scode, pcode, quantity, unit, amount, pcarrier, pterms, drnumber, date) Values ('" + Combo1.Text + "','" + Combo2.Text + "','" + Text1.Text + "','" + Text2.Text + "','" + Text3.Text + "','" + Text4.Text + "','" + Text5.Text + "','" + Text6.Text + "','" + Text7.Text + "')"


and

rs1.Open "select * from Product where pcode='" & Combo2.Text & "'", cn, adOpenKeyset, adLockPessimistic

must be

rs1.Open "select * from Product where pcode='" & Combo2.Text & "'", cn, adOpenDynamic, adLockOptimistic

remove the statement
[code[
rs.close
[/code]



Regards
Shaik Akthar
Last edited by aktharshaik : Dec 1st, 2008 at 8:07 am.
Reply With Quote  
Posts: 161
Reputation: ryan311 has a little shameless behaviour in the past 
Solved Threads: 1
ryan311 ryan311 is offline Offline
Junior Poster

Re: About Updating a Record in adodb

  #3  
Dec 1st, 2008
still have a synthax error
Reply With Quote  
Posts: 161
Reputation: ryan311 has a little shameless behaviour in the past 
Solved Threads: 1
ryan311 ryan311 is offline Offline
Junior Poster

Re: About Updating a Record in adodb

  #4  
Dec 1st, 2008
in the insert into
Reply With Quote  
Posts: 293
Reputation: aktharshaik is an unknown quantity at this point 
Solved Threads: 35
aktharshaik's Avatar
aktharshaik aktharshaik is offline Offline
Posting Whiz in Training

Re: About Updating a Record in adodb

  #5  
Dec 1st, 2008
check out the syntax. u have added single quotes to the numeric fields also. remove them.
'" + Combo1.Text + "','" + Combo2.Text + "','" + Text1.Text + "','" + Text2.Text + "','" + Text3.Text + "','" + Text4.Text + "','" + Text5.Text + "','" + Text6.Text + "','" + Text7.Text + "'
'must be
'" + Combo1.Text + "','" + Combo2.Text + "'," + Text1.Text + "," + Text2.Text + "," + Text3.Text + "," + Text4.Text + "," + Text5.Text + "," + Text6.Text + "," + Text7.Text + ")"

I am unable to figure out the numeric fields from ur query, but that's the problem.

Put quotes for text fields and remove them for numeric fields.


Regards
Shaik Akthar
Reply With Quote  
Posts: 161
Reputation: ryan311 has a little shameless behaviour in the past 
Solved Threads: 1
ryan311 ryan311 is offline Offline
Junior Poster

Re: About Updating a Record in adodb

  #6  
Dec 1st, 2008
huhuhu sir still an error ocured in insert into
Reply With Quote  
Posts: 293
Reputation: aktharshaik is an unknown quantity at this point 
Solved Threads: 35
aktharshaik's Avatar
aktharshaik aktharshaik is offline Offline
Posting Whiz in Training

Re: About Updating a Record in adodb

  #7  
Dec 1st, 2008
post the code again now,

and which of ur fields are Text and which of them are numeric in the database

and also the error message please.

Regards
Shaik Akthar
Reply With Quote  
Posts: 161
Reputation: ryan311 has a little shameless behaviour in the past 
Solved Threads: 1
ryan311 ryan311 is offline Offline
Junior Poster

Re: About Updating a Record in adodb

  #8  
Dec 1st, 2008
wrong number of agruments thats is the eror!
Reply With Quote  
Posts: 293
Reputation: aktharshaik is an unknown quantity at this point 
Solved Threads: 35
aktharshaik's Avatar
aktharshaik aktharshaik is offline Offline
Posting Whiz in Training

Re: About Updating a Record in adodb

  #9  
Dec 1st, 2008
post the code again now,

and which of ur fields are Text and which of them are numeric in the database

and also the error message please.

Regards
Shaik Akthar
Reply With Quote  
Posts: 161
Reputation: ryan311 has a little shameless behaviour in the past 
Solved Threads: 1
ryan311 ryan311 is offline Offline
Junior Poster

Re: About Updating a Record in adodb

  #10  
Dec 1st, 2008
If Combo1.Text = "" Then
MsgBox "Please Choose Supplier Code"
Combo1.SetFocus
Exit Sub
End If
If Combo2.Text = "" Then
MsgBox "Please Choose Product Code"
Combo2.SetFocus
Exit Sub
End If
If Text1.Text = "" Then
MsgBox "Please Input the Quantity"
Text1.SetFocus
Exit Sub
End If
If Text3.Text = "" Then
MsgBox "Please Input the Amount"
Text3.SetFocus
Exit Sub
End If
cn.Execute "Insert Into Deliver (scode, pcode, quantity, unit, amount, pcarrier, pterms, drnumber, date) Values ('" + Combo1.Text + "','" + Combo2.Text + "'," + Text1.Text + "," + Text2.Text + "," + Text3.Text + "," + Text4.Text + "," + Text5.Text + "," + Text6.Text + "," + Text7.Text + ")", cn, adOpenKeyset, adLockPessimistic
rs1.Open "select * from Product where pcode='" & Combo2.Text & "'", cn, adOpenDynamic, adLockOptimistic
If rs1.RecordCount > 0 Then
rs1.Fields![pstock] = Val(rs1.Fields![pstock]) + Val(Text1.Text)
rs1.Update
rs1.Close
MsgBox "The Product has been save successfully", vbInformation
Combo1.Text = ""
Combo2.Text = ""
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Call Form_Load
Else
MsgBox "OHH NO!", vbInformation
End If

Compile Error:

wrong Number of agruments or invalid property assignment
Last edited by ryan311 : Dec 1st, 2008 at 9:41 am. Reason: i forgot
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Views: 1023 | Replies: 25 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:12 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC