Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old August 14th, 2003, 12:38 PM
slconsult slconsult is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Essex, ON
Posts: 18 slconsult User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 5 m 35 sec
Reputation Power: 0
trying to define recordset when loading a form

The following is my code for my form load event. Can anyone please tell me why the Rs in Rs.Open is underlined. I am connected to the database. The help says that cn_sdurward.return_connection cannot be converted to string.

Any help would be appreciated.



Dim cn_sdurward As New database_connections("SDURWARD", "SQL")
Dim SQL As String
Dim Rs As New ADODB.Connection()



SQL = "SELECT * FROM trecipes"
Rs.Open(SQL, cn_sdurward.return_connection, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockBatchOptimistic)

Rs.MoveFirst()
Call ShowData()

Reply With Quote
  #2  
Old August 15th, 2003, 08:07 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
I do not know your database_connections object. Where does it originate from? From the looks of the lack of capitalization it is not part of vb by default. Are you sure return_connection works as you expect?

Reply With Quote
  #3  
Old August 15th, 2003, 09:59 AM
slconsult slconsult is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Essex, ON
Posts: 18 slconsult User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 5 m 35 sec
Reputation Power: 0
trying to define recordset when loading a form

It doesn't matter if I have CAPS on or not. I can retrieve my data through the server explorer.

This is exactly how it is written.

Public Class DATABASE_CONNECTION

Private CN_SDURWARD As New DATABASE_CONNECTIONS("SDURWARD", "SQL")
Private SQL As String
Private Rs As New ADODB.Connection()

Rs.Open(SQL, CN_SDURWARD.RETURN_CONNECTION, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockBatchOptimistic)



End Class


I hope this helps you in helping me.

Reply With Quote
  #4  
Old August 15th, 2003, 10:04 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
I don't quite think you understand what I posted earlier.
I took by the fact that the class does not follow standard vb captialization that is was not part of vb by default, i.e. it is something that you created.

In that context, are you sure that RETURN_CONNECTION contains the value(s) that you assume they do?

Reply With Quote
  #5  
Old August 15th, 2003, 10:37 AM
slconsult slconsult is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Essex, ON
Posts: 18 slconsult User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 5 m 35 sec
Reputation Power: 0
trying to define recordset when loading a form

Hi again,

Below is the class I reference in my previous statements. Hope this helps you.

Public Class DATABASE_CONNECTIONS

Private M_CONNECTION As ADODB.Connection
Private M_DATABASE_NAME As String
Private M_SERVER As String


Public Sub New(ByVal DATABASE_NAME As String, ByVal SERVER As String)
M_DATABASE_NAME = DATABASE_NAME
M_SERVER = SERVER
M_CONNECTION = New ADODB.Connection()
Try
Select Case Trim(SERVER)
Case "SQL"
Select Case Trim(DATABASE_NAME)
Case "RECIPES"
With M_CONNECTION
.Provider = "sqloledb"
.ConnectionString = "Server=SDURWARD;User ID=sdurward;pwd=june13,1987"
.Open()
.DefaultDatabase = "trecipes"
End With

End Select


Case Else
MsgBox("UNKNOWN DATABASE : " & DATABASE_NAME & " SERVER: " & SERVER)
End Select
Catch M_DATACONNECTIONS As Exception
MsgBox("ERROR IN OPENING CONNECTION " & DATABASE_NAME & " SERVER: " & _
SERVER & vbCrLf & M_DATACONNECTIONS.Message)
End Try

End Sub
Public Sub Close_Connection()
If M_CONNECTION.State = 1 Then M_CONNECTION.Close()
End Sub

' PUBLIC METHODS
Public Function GET_DATABASE_NAME() As String
Return M_DATABASE_NAME
End Function
Public Function GET_SERVER() As String
Return M_SERVER
End Function
Public Function RETURN_CONNECTION() As ADODB.Connection
Return M_CONNECTION
End Function
End Class

Reply With Quote
  #6  
Old August 15th, 2003, 11:02 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
I think this: Private Rs As New ADODB.Connection() should be a recordset instead of a connection.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > trying to define recordset when loading a form


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway