Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / July 2007



Tip: Looking for answers? Try searching our database.

Connect to SQL database

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert - 19 Jul 2007 18:42 GMT
Hello;
I'm on XP Pro, using VB6 and an SQL Server Database on our server.  I can't
seem to connect - keep getting "Error 3709 - The connection cannot be used
to perform this operation. It is either closed or invalid in this context".
This error happens on the .open statement.  Here's the code:

u = "sa"
p = "pwd"
dsource = "mysvr"
cata = "myDatabase"

Dim bDb As New adodb.Connection
Dim bRs As New adodb.Recordset
Dim Report As New CrystalReport1

   With bDb

       .Provider = "SQLOLEDB"
       .ConnectionString = "User ID=" & u & _
                                      ";Password=" & p & _
                                     ";Data Source=" & dsource & _
                                     ";Catalog=" & cata

   End With

   With bRs

       .CursorLocation = adUseServer
       .LockType = adLockReadOnly
       .CursorType = adOpenStatic

       .Open "SELECT ORDER_HEADER.customer_name FROM ORDER_HEADER", bDb

   End With
Al Reid - 19 Jul 2007 18:55 GMT
> Hello;
> I'm on XP Pro, using VB6 and an SQL Server Database on our server.  I can't
[quoted text clipped - 30 lines]
>
>     End With

Robert,

You need to Open the connection before using it with the Recordset.Open.

--
Al Reid
Robert - 19 Jul 2007 19:10 GMT
>> Hello;
>> I'm on XP Pro, using VB6 and an SQL Server Database on our server.  I
[quoted text clipped - 40 lines]
> --
> Al Reid

Thanks Al!! that was the problem - I feel stupid!
However, now when I execute the following code to open crviewer and view the
report, I get: logon failed. Details: [Database Vendor Code: 18456]

additional code:
   Report.Database.SetDataSource bRs
   crViewer1.ReportSource = Report
   crViewer1.ViewReport

thanks for any help!!
Robert
Al Reid - 19 Jul 2007 19:34 GMT
> Thanks Al!! that was the problem - I feel stupid!
> However, now when I execute the following code to open crviewer and view the
[quoted text clipped - 7 lines]
> thanks for any help!!
> Robert

Sorry, Robert, I can't help with that.  It's been too many years since I used Crystal with VB6.

Signature

Al Reid

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.