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 (VB4.0 - Trouble with MDB, Visdata, Datman)Next Topic (VB SQL - Fieldname,etc - simple PROBLEM) New Topic New Poll Post Reply
AndreaVB Forum : Database : problems inserting data into sql7
Poster Message
morsas
Level: Trainee

Registered: 12-04-2006
Posts: 3

icon problems inserting data into sql7

I made a connection to sql server 7 with VB 6.0 and run a query to insert data into a table.
I must use the .refresh method at the end of the sentence for the data to be inserted, the data is inserted with no problem but the app gives me a message refering to the .refresh method it says. operation is not allowed if the object is closed.

Can anybody help me?

12-04-2006 at 01:33 AM
View Profile Send Email to User Show All Posts | Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: problems inserting data into sql7

Hi

It sounds like you're doing the refresh after your connection is closed, but you should not need to refresh the connection anyway. Do you mean to refresh a grid?.

Post your code up and i'll take a look.

Steve  

12-04-2006 at 07:50 AM
View Profile Send Email to User Show All Posts | Quote Reply
morsas
Level: Trainee

Registered: 12-04-2006
Posts: 3
icon Re: problems inserting data into sql7

With Adodc1
    .ConnectionString = "driver={SQL server};" & _
        "server=jromero;uid=pruebas;pwd=pruebas;database=Pruebas"
    .CursorType = adOpenDynamic
    .CommandType = adCmdUnknown
    .RecordSource = "DECLARE @callingnum VARCHAR(5)" & _
                    "SET @callingnum=10295" & _
                    "insert into cti_events (extension) values (@callingnum)"
    .Refresh


with the refresh method the insert works right but i see the error message. If i delete the refresh method i don't see the message but the insert doesn't work.

Thank you in advance.

[Edited by morsas on 12-04-2006 at 06:01 PM GMT]

13-04-2006 at 12:01 AM
View Profile Send Email to User Show All Posts | Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: problems inserting data into sql7

Try it this way

With Adodc1
    .ConnectionString = "driver={SQL server};" & _
        "server=jromero;uid=pruebas;pwd=pruebas;databaseruebas"
    .CursorType = adOpenDynamic
    .CommandType = adCmdText
    .RecordSource = "Select * from cti_events"
    .RecordSet.AddNew
    .RecordSet("extension") = 10295
    .RecordSet.Update

end with



Steve

13-04-2006 at 08:10 AM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: problems inserting data into sql7

May I ask why are you using an ADODC control just to insert a record? Why dont you use connection object instead? and why are you using ODBC driver in connection string, since this way one extra layer is involved in communication?

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

15-04-2006 at 12:13 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : problems inserting data into sql7
Previous Topic (VB4.0 - Trouble with MDB, Visdata, Datman)Next Topic (VB SQL - Fieldname,etc - simple PROBLEM) 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