Connection.execute querry not saving the data in database.-VBForums
Results 1 to 11 of 11

Thread: Connection.execute querry not saving the data in database.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2012
    Posts
    23

    Connection.execute querry not saving the data in database.

    Dear Sir,

    i am putting some data in the database through vb application through below qeurrry.

    connection.execute("delete from table where ID = 'ABC' ")

    qurry works fine and i can see the correct results. but when i close and run again this application, it appears that above querry has not saved the result or has not updated the database.

    Point to be noted, database is of SQL 2008, and database resides in another computer machine whithin the network.

    please help.

    Thanks and best regards.
    Imran Khaldi

  2. #2
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Connection.execute querry not saving the data in database.

    Moved From The CodeBank (which is for sharing code rather than posting questions )
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  3. #3
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    3,488

    Re: Connection.execute querry not saving the data in database.

    This is almost certainly due the settings for the database in your project. You're database is being copied every time you run your project and your delete is being performed on the copy, not the original. When you finish running the copy is discarded and your changes are lost. Have a look round for a member called JMcIllhiney. I'm pretty sure he's got a link in his signiature which explains it very well and tells you how to fix the problem.
    When one of my minions says, "Hey, he's just one guy, what can he do?" I say "This"... and shoot them.

    The problem with putting your lair in a volcano is keeping your robot army from melting.

    I know that the human being and the fish can coexist peacefully - George Bush

  4. #4
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    3,488

    Re: Connection.execute querry not saving the data in database.

    here you go. I found the link for you. The forums being a bit glitchy at the moment so I can't post it as a link but here's the url.
    http://msdn.microsoft.com/en-us/libr...89(VS.80).aspx

    OK, it interpreted the url automatically, nice.
    When one of my minions says, "Hey, he's just one guy, what can he do?" I say "This"... and shoot them.

    The problem with putting your lair in a volcano is keeping your robot army from melting.

    I know that the human being and the fish can coexist peacefully - George Bush

  5. #5
    PowerPoster
    Join Date
    May 2002
    Posts
    25,485

    Re: Connection.execute querry not saving the data in database.

    Hmmmm Funky read something different from me...
    while his assessment jives with my initial reaction.... this bit:
    database is of SQL 2008, and database resides in another computer machine whithin the network.
    Seems to indicate a SQL Server sistuation... and not necessarily a local files issue... I could be wrong though.

    That said... I NEVER... EVER, use the connection.execute that way... personally I think it's more prudent and better to create a connection, create a command, create parameters as necessary, and then execute the COMMAND...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    3,488

    Re: Connection.execute querry not saving the data in database.

    Seems to indicate a SQL Server sistuation
    Ooh, actually you're probably right. I clearly wasn't paying attention.
    When one of my minions says, "Hey, he's just one guy, what can he do?" I say "This"... and shoot them.

    The problem with putting your lair in a volcano is keeping your robot army from melting.

    I know that the human being and the fish can coexist peacefully - George Bush

  7. #7
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    88,603

    Re: Connection.execute querry not saving the data in database.

    Is your application written in VB6 or VB.NET? You appear to be using ADO so that would suggest VB6, although it would work in VB.NET too.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jun 2012
    Posts
    23

    Re: Connection.execute querry not saving the data in database.

    thanks for your openion but i am still unable to resolve the matter.
    for you reference i am using quetty as under.


    ============
    dim insertquerry as stringg

    insertquerry= "insert into customer values ('name', 'id', 'address')"

    connection.execute(inserquerry)
    ===========

    waiting for further help to resolve the matter.
    Thanks and best regards.

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jun 2012
    Posts
    23

    Re: Connection.execute querry not saving the data in database.

    thanks for your openion but i am still unable to resolve the matter.
    for you reference i am using quetty as under.


    ============
    dim insertquerry as stringg

    insertquerry= "insert into customer values ('name', 'id', 'address')"

    connection.execute(inserquerry)
    ===========

    waiting for further help to resolve the matter.
    Thanks and best regards.

  10. #10
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,241

    Re: Connection.execute querry not saving the data in database.

    We're none of us going to get very much further if you don't indicate how you're setting up the connection and, more importantly, demonstrate that you are opening the connection prior to the command. You won't necessarily get an error if you execute a command on a connection that is closed but it certainly won't do what you want it to.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  11. #11
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    88,603

    Re: Connection.execute querry not saving the data in database.

    I'm still waiting for an answer to my question too:
    Quote Originally Posted by jmcilhinney View Post
    Is your application written in VB6 or VB.NET? You appear to be using ADO so that would suggest VB6, although it would work in VB.NET too.
    You say that you're waiting for further help but you refuse to provide information that we've requested in order to help you. Is your time inherently more valuable than ours?

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.