Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey...hi!!!

actually the thing is that i'm new to vb and i'm working on 1 project..
just for fun.
n i am stuck..
means i can't upload means edit the access database with vb6.0
here is the thing

rec.Open "insert into Payment values ('" & Combo1.Text & "','" & txtTa.Text & "','" & Text4.Text & "','" & Label11.Caption & "')", con, adOpenStatic

this is the command that i use for INSERT the row..

and

rec.Open "update Payment set amountPaybal='" & txtTa.Text & "',paidAmount='" & Text4.Text & "',date='" & Label11.Caption & "' where id=" & Combo1.Text & "", con, adOpenStatic

this is used to edit/update it..
but it's not working ..says update query false something like that

can anyone help me..??
please help me out with this..
Posted

I think your problem might be that the connection is using adOpenStatic.

try adOpenDynamic. this should allow you to read and write.

Also go to help files and look up "Fields" and "recordsets"

Hope this will help
 
Share this answer
 
Comments
Maciej Los 26-May-15 15:53pm    
The problem is that OP wants to use ADODB.Recordset wrong way. Please, see my answer.
First thing: check your data.
Because you don't list the columns you are trying to INSERT into, Access assumes that you want to insert data starting from the first column - so if you have an automatic ID column at the beginning - and it's very common - the INSERT will fail, because you aren't allowed to write to them. So look at your table definition, check the data in the table, and make sure that at least one row matches the id value you are trying to UPDATE later.
ANd then change your query to list the columns:
SQL
INSERT INTO Payment (columnName1, columnName2, columnName3, columnName4) VALUES (...


Second - and this is really important - don't do it like that! Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.
See here: http://www.vbforums.com/showthread.php?552665-Database-How-do-I-use-an-ADO-Command-object[^]

If that doesn't fix it, we need to know the exact error message, and the line that it appears on.
 
Share this answer
 
You have to use ADODB.Command[^] together with Execute[^] method to update your data.

For further details, please see:
Using ADO with Microsoft Visual Basic[^]
ADO Code Examples in Visual Basic[^]
How to Reference ADO 2.0 in Visual Basic[^]
 
Share this answer
 
it's good to have you..
i need to update no insert..
can you help me with that???

con.Close
    con.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\Users\Public\Documents\SAMPLE.mdb"
    If con.State = adStateOpen Then
    con.Close
    End If
    con.Open
    rec.Open "select * from Payment1", con, adOpenStatic
    While rec.BOF = False
    If rec.State = adStateOpen Then
    rec.Close
    End If
    rec.Open "update Payment1 set amountPaybal='" & txtTa.Text & "',paidAmount='" & Text4.Text & "',date='" & Label11.Caption & "' where id=" & Combo1.Text & "", con, adOpenStatic
    MsgBox "successfully inserted"
    Wend


this is what i have on update button
but it's not working
 
Share this answer
 
Comments
Maciej Los 25-May-15 17:42pm    
Not an answer!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900