|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
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() |
|
#2
|
||||
|
||||
|
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?
|
|
#3
|
|||
|
|||
|
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. |
|
#4
|
||||
|
||||
|
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? |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
||||
|
||||
|
I think this: Private Rs As New ADODB.Connection() should be a recordset instead of a connection.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > trying to define recordset when loading a form |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|