943,929 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Dec 1st, 2008
0

About Updating a Record in adodb

Expand Post »
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 7:45 am. Reason: i forgot something
Similar Threads
Reputation Points: 3
Solved Threads: 5
Posting Whiz in Training
ryan311 is offline Offline
254 posts
since Jul 2008
Dec 1st, 2008
0

Re: About Updating a Record in adodb

Corrections
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 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
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 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

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. rs1.Open "select * from Product where pcode='" & Combo2.Text & "'", cn, adOpenKeyset, adLockPessimistic

must be

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 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 9:07 am.
Reputation Points: 26
Solved Threads: 40
Posting Whiz
aktharshaik is offline Offline
316 posts
since Aug 2008
Dec 1st, 2008
0

Re: About Updating a Record in adodb

still have a synthax error
Reputation Points: 3
Solved Threads: 5
Posting Whiz in Training
ryan311 is offline Offline
254 posts
since Jul 2008
Dec 1st, 2008
0

Re: About Updating a Record in adodb

in the insert into
Reputation Points: 3
Solved Threads: 5
Posting Whiz in Training
ryan311 is offline Offline
254 posts
since Jul 2008
Dec 1st, 2008
0

Re: About Updating a Record in adodb

check out the syntax. u have added single quotes to the numeric fields also. remove them.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. '" + Combo1.Text + "','" + Combo2.Text + "','" + Text1.Text + "','" + Text2.Text + "','" + Text3.Text + "','" + Text4.Text + "','" + Text5.Text + "','" + Text6.Text + "','" + Text7.Text + "'
  2. 'must be
  3. '" + 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
Reputation Points: 26
Solved Threads: 40
Posting Whiz
aktharshaik is offline Offline
316 posts
since Aug 2008
Dec 1st, 2008
0

Re: About Updating a Record in adodb

huhuhu sir still an error ocured in insert into
Reputation Points: 3
Solved Threads: 5
Posting Whiz in Training
ryan311 is offline Offline
254 posts
since Jul 2008
Dec 1st, 2008
0

Re: About Updating a Record in adodb

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
Reputation Points: 26
Solved Threads: 40
Posting Whiz
aktharshaik is offline Offline
316 posts
since Aug 2008
Dec 1st, 2008
0

Re: About Updating a Record in adodb

wrong number of agruments thats is the eror!
Reputation Points: 3
Solved Threads: 5
Posting Whiz in Training
ryan311 is offline Offline
254 posts
since Jul 2008
Dec 1st, 2008
0

Re: About Updating a Record in adodb

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
Reputation Points: 26
Solved Threads: 40
Posting Whiz
aktharshaik is offline Offline
316 posts
since Aug 2008
Dec 1st, 2008
0

Re: About Updating a Record in adodb

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 10:41 am. Reason: i forgot
Reputation Points: 3
Solved Threads: 5
Posting Whiz in Training
ryan311 is offline Offline
254 posts
since Jul 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Visual Basic 6 - Hide Folders
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Would like to get back VB ver 6.0 source code





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC