Why wont this open? 
Author Message
 Why wont this open?

I posted above about multiple ado objects, and decided to try creating an
object variable...
Keep in mind I'm new to this...

Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset

Private Sub Command1_Click()

con.Open "DSN=dw test"
rs.Open
rs.AddNew
rs.Fields("name") = Text1.Text
rs.Fields("age") = Text2.Text
rs.Update
End Sub

It stops at rs.open error 3709 Operation is not allowed on an object
referencing a closed or invalid connection.

the DB is DW test, and the table is test.
Am I doing something wrong?  I'm trying to do more than populate a grid.

Thanks for the help,

Dean



Tue, 07 Sep 2004 03:59:40 GMT  
 Why wont this open?
Hi,

Problem here is that connection was not opened. I think
this is because of space between *dw*  and *test*. Try to
make it like a one word or inclose it into single quotes

con.Open "DSN='dw test'"

Val

Quote:
>-----Original Message-----
>I posted above about multiple ado objects, and decided to
try creating an
>object variable...
>Keep in mind I'm new to this...

>Dim con As New ADODB.Connection
>Dim rs As New ADODB.Recordset

>Private Sub Command1_Click()

>con.Open "DSN=dw test"
>rs.Open
>rs.AddNew
>rs.Fields("name") = Text1.Text
>rs.Fields("age") = Text2.Text
>rs.Update
>End Sub

>It stops at rs.open error 3709 Operation is not allowed
on an object
>referencing a closed or invalid connection.

>the DB is DW test, and the table is test.
>Am I doing something wrong?  I'm trying to do more than
populate a grid.

>Thanks for the help,

>Dean

>.



Tue, 07 Sep 2004 04:23:41 GMT  
 Why wont this open?
You just haven't associated your recordset with your connection object; to
do so, add the following line after con.open:

set rs.ActiveConnection = con

Hope this helps!

Steven Bras, MCSD
Microsoft Developer Support/Visual Basic WebData

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.



Wed, 08 Sep 2004 08:19:37 GMT  
 Why wont this open?
And to round things out, you need to specify a select statement, e.g.:

rs.Open "select name, age from test", con

HTH,

Simon Taylor
Resource Data, Inc.



Quote:
> I posted above about multiple ado objects, and decided to try creating an
> object variable...
> Keep in mind I'm new to this...

> Dim con As New ADODB.Connection
> Dim rs As New ADODB.Recordset

> Private Sub Command1_Click()

> con.Open "DSN=dw test"
> rs.Open
> rs.AddNew
> rs.Fields("name") = Text1.Text
> rs.Fields("age") = Text2.Text
> rs.Update
> End Sub

> It stops at rs.open error 3709 Operation is not allowed on an object
> referencing a closed or invalid connection.

> the DB is DW test, and the table is test.
> Am I doing something wrong?  I'm trying to do more than populate a grid.

> Thanks for the help,

> Dean



Wed, 08 Sep 2004 09:21:06 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. ActiveX wont deploy to Win 2K - why, Why WHY

2. why wont this work ???

3. Why wont this line co;pile?

4. why wont scripting work?

5. why wont this work?

6. Why wont this code work

7. Why wont This If statement work ?

8. Why wont this numeric comparison work ?

9. Why wont vb4 16bit install in win3.11

10. Why wont this work!? Please help

11. Why in gods name wont this work?

12. Drop Down Navigation - Why wont thiw work in ie3.0

 

 
Powered by phpBB® Forum Software