borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Compressing Access DB)Next Topic (Using Charts in AccessVBA) New Topic New Poll Post Reply
AndreaVB Forum : Database : vb6.exe-Application error?? Solved Topic
Poster Message
di_2006
Level: Protégé

Registered: 03-03-2006
Posts: 4

icon vb6.exe-Application error??

I am doing a project with VB6.0 as the front-end and Access 2003 as the back-end.

I have a database by the name "taxi" & a table by the name "taxi_details".Following is the code to update an entry in the database.

con.Open App.Path & "\Taxi.mdb"
sql2 = "update taxi_details set person='" & Text3.Text & "'"
sql2 = sql2 & ",depart='" & Text4.Text & "',purpose='" & Text5.Text & "', amount='" & Text6.Text & "',kilometres='" & Text7.Text & "' where taxi_no='" & Form2.Text1.Text & "' and date=#" & Form2.Text2.Text & "#"
rs.Open sql2, con, adOpenDynamic, adLockOptimistic
con.Execute sql2, rs


After running the code, the particular entry gets updated but I get a "vb6.exe-Application Error"saying-

The instruction at "0x...." referenced memory at "0x00000000".The memory could not be "read".
Click on OK to terminate the program
Click on CANCEL to debug the program.

and my VB application gets terminated. I am facing the same problem while adding a new entry to the database too.Following is the code to add a new entry:

sql1 = "insert into taxi_details values('" & Text1.Text & "',#" & Text2.Text & "#,'" & Text3.Text & "','" & Text4.Text & "','" & Text5.Text & "','" & Text6.Text & "','" & Text7.Text & "')"
    con.Execute sql1, rs

I am really confused with this particular problem and I donot understand whats the cause.

PLEASE HELP!
I can attach the entire project, if anyone wants to see the whole code..
Please let me know.Thanks in advance!

03-03-2006 at 06:46 AM
View Profile Send Email to User Show All Posts | Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: vb6.exe-Application error??

Try removing the rs.open lines you don't need them. You only need that if your returning a recordset which your not.

The con.execute is enough to execute your sql statement.


Steve  

03-03-2006 at 03:02 PM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: vb6.exe-Application error??

And not just that, syntax for Execute method is as following

connection.Execute CommandText, RecordsAffected, Options


in your example, if you dont want to know the number of rows that are affected, it should be

con.Execute sql2,,adexecutenorecords


____________________________
If you find the answer helpful, please mark this topic as solved.

03-03-2006 at 06:46 PM
View Profile Send Email to User Show All Posts | Quote Reply
di_2006
Level: Protégé

Registered: 03-03-2006
Posts: 4
icon Re: vb6.exe-Application error??

Thanks Steve and Goran..It works!!!

04-03-2006 at 04:30 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : vb6.exe-Application error?? Solved Topic
Previous Topic (Compressing Access DB)Next Topic (Using Charts in AccessVBA) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder