Click here to Skip to main content
16,005,316 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: creating a "please wait" dialog Pin
sagmam12-Sep-04 2:48
sagmam12-Sep-04 2:48 
GeneralRe: creating a "please wait" dialog Pin
jonathan156-Sep-04 4:27
jonathan156-Sep-04 4:27 
GeneralConnecting to SQL Server DB Pin
RamBhatt5-Sep-04 4:13
RamBhatt5-Sep-04 4:13 
GeneralRe: Connecting to SQL Server DB Pin
Mekong River5-Sep-04 7:27
Mekong River5-Sep-04 7:27 
GeneralRe: Connecting to SQL Server DB Pin
RamBhatt5-Sep-04 20:03
RamBhatt5-Sep-04 20:03 
GeneralRe: Connecting to SQL Server DB Pin
jonathan156-Sep-04 4:38
jonathan156-Sep-04 4:38 
GeneralRe: Connecting to SQL Server DB Pin
Mekong River6-Sep-04 5:11
Mekong River6-Sep-04 5:11 
Generalsuccess Pin
RamBhatt6-Sep-04 18:25
RamBhatt6-Sep-04 18:25 
'Thank you very much sir. it worked as expected. i've some doubts.
'i don't have any ref books at present thatz why i'm putting questions here.

'i chose ActiveX Data Objects 2.5 - is it required to change 'sqloledb' to some other driver?
'in ODBC the setting was SQLServer Authentication, but it still worked, why?
'could you please tell me the difference between RDO and ADO?

to komsot man-sir u told me about wizard whatz it? how to use it? is it something related to 'user connection'?

'the following code, which i got from a book, gave error. could you please tell me why?

the RDODatabase is a class that i got from book. the relevant methods i've pasted down
history

1. when i ran the code as it is it showed 424 object not found
2. when i tried to debug (i don't know much about objects to use class,pls help me) it showed runtime error 40002, data source name not found and no default driver specified. this errmsg was not from my errpara! it was from the class errhandler.

----------------

Dim objDatabase As RDODatabase

'-------my code begins
Public Sub ReadFromStud()

On Error GoTo errPara

'connect to remote DB

'--my code to debug!!
Set objDatabase = New RDODatabase
objDatabase.Connect "ODBCTest", "test", "sa", "sqluser"
'-----

'RDODatabase.Connect "ODBCTest", "test", "sa", "sqluser"

'select query
'RDODatabase.Execute "SELECT * FROM Stud"

Do Until RDODatabase.EOF 'repeat till eof
Debug.Print RDODatabase("idx"), RDODatabase("Name")
RDODatabase.MoveNext
Loop

Exit Sub

errPara:
MsgBox Err & Chr(13) & Err.Description

End Sub
'----my code ends

'the class def is as follows...
'Public Function Connect(Optional strDSN As String, Optional strDatabaseName As String, Optional strUserName As String, Optional strPassword As Variant) As Long
'Call connect to attach to an RDO/ODBC datasource and be happy.

' If ConLiveFlag Then Exit Function

' On Error GoTo Connect_Error

' If strDSN <> "" Then mvarServerName = strDSN
' If strDatabaseName <> "" Then mvarDatabaseName = strDatabaseName
' If strUserName <> "" Then mvarUsername = strUserName
' If Not IsMissing(strPassword) Then mvarPassword = strPassword
' If mvarQueryTimeout = 0 Then mvarQueryTimeout = DEFAULT_QUERYTIMEOUT
' If mvarLoginTimeout = 0 Then mvarLoginTimeout = DEFAULT_LOGINTIMEOUT
'
' If ConLiveFlag Then Call Disconnect
'
' With mvarRDOConnection
' .Connect = ODBCConnectionString
' .LoginTimeout = mvarLoginTimeout
' .CursorDriver = rdUseOdbc
' On Error Resume Next
' .QueryTimeout = mvarQueryTimeout
' On Error GoTo Connect_Error
' .EstablishConnection rdDriverNoPrompt 'open the connection, if named DSN does not exist, ODBC will prompt the user to create one or select a different one
' End With
'
' DoEvents
'
' ConLiveFlag = True
' Connect = 0
'Exit Function
'Connect_Error:
'
' Call HandleError
'
'End Function

'Public Sub Execute(sSQL As String, Optional DatasetType As Variant, Optional Mute As Boolean)
'If the Mute param is True, then no dataset is returned from the server, as in an INSERT query or
'DROP query.
'On Error GoTo Execute_Error
'
' If mvarRDOConnection.rdoQueries.Count Then mvarQueryObject.Close
' Set mvarQueryObject = mvarRDOConnection.CreateQuery(QSQL, sSQL)
' If IsMissing(DatasetType) Then DatasetType = DATASETTYPES.DYNAMIC
'
' 'If we are mute, execute without results
' If Mute Then
' mvarQueryObject.Execute
' Else
' If DatasetType = DATASETTYPES.FORWARD_ONLY Then
' Set mvarRDOResults = mvarQueryObject.OpenResultset(rdOpenForwardOnly, rdConcurReadOnly)
' ElseIf DatasetType = DATASETTYPES.DYNAMIC Then
' Set mvarRDOResults = mvarQueryObject.OpenResultset(rdOpenKeyset, rdConcurRowVer)
' End If
' DoEvents
' boolResultsAvailable = True
' End If
'
'Exit Sub
'
'Execute_Error:
'
' Call HandleError
'
'End Sub

'-------------------
'Public Sub MoveNext()
'On Error GoTo MoveNext_Error
' mvarRDOResults.MoveNext
'Exit Sub
'MoveNext_Error:
' Call HandleError
'End Sub

'Private Sub GenDatabaseError()
' Dim MSG As String
' MSG = Err.Description + "|"
'
' For Each DataErr In rdoErrors
' MSG = MSG + "[" & DataErr.Number & "]" & DataErr.Description & Chr(13)
' Next DataErr
'
' lErrorNumber = Err.Number
' sErrorMessage = MSG
'
' Err.Raise lErrorNumber, ERROR_SOURCE, sErrorMessage

'End Sub

'Private Sub HandleError()

' Dim lErrNum As Long
' Dim sErrMsg As String

' lErrNum = Err.Number
' sErrMsg = Err.Description

' If lErrNum = 40002 Then
' Call GenDatabaseError
' Else
' Err.Raise lErrNum, ERROR_SOURCE, sErrMsg
' End If

'End Sub

GeneralRe: success Pin
Mekong River7-Sep-04 21:42
Mekong River7-Sep-04 21:42 
GeneralRe: success Pin
RamBhatt8-Sep-04 3:44
RamBhatt8-Sep-04 3:44 
QuestionHow to use Pin
Murtuza Husain Miyan Patel5-Sep-04 4:08
professionalMurtuza Husain Miyan Patel5-Sep-04 4:08 
AnswerRe: How to use Pin
Mekong River5-Sep-04 7:22
Mekong River5-Sep-04 7:22 
GeneralDeleting contents of history folder Pin
nitin_ion4-Sep-04 0:33
nitin_ion4-Sep-04 0:33 
GeneralRe: Deleting contents of history folder Pin
Mekong River6-Sep-04 5:28
Mekong River6-Sep-04 5:28 
GeneralRe: Deleting contents of history folder Pin
nitin_ion6-Sep-04 19:00
nitin_ion6-Sep-04 19:00 
GeneralRe: Deleting contents of history folder Pin
Mekong River6-Sep-04 21:31
Mekong River6-Sep-04 21:31 
GeneralText color on forms Pin
Kevnar3-Sep-04 21:17
Kevnar3-Sep-04 21:17 
GeneralCrystal Report 9 + VB6 Pin
spn3-Sep-04 20:37
spn3-Sep-04 20:37 
GeneralRe: Crystal Report 9 + VB6 Pin
Anonymous5-Sep-04 17:13
Anonymous5-Sep-04 17:13 
GeneralRetrieve TopMost Visible Row Pin
beowulfagate3-Sep-04 19:55
beowulfagate3-Sep-04 19:55 
GeneralCreate city Map to locate location Pin
Rashid Ali Khan3-Sep-04 16:43
Rashid Ali Khan3-Sep-04 16:43 
GeneralRe: Context Sensitive Help ? on a toolbar or button Pin
Anonymous3-Sep-04 11:26
Anonymous3-Sep-04 11:26 
GeneralRe: Context Sensitive Help ? on a toolbar or button Pin
siacom3-Sep-04 11:48
siacom3-Sep-04 11:48 
GeneralProblem regarding &quot;Unicode&quot; and File Handling Pin
eshban2843-Sep-04 9:29
eshban2843-Sep-04 9:29 
GeneralContext Sensitive Help ? on a toolbar or button Pin
siacom3-Sep-04 7:55
siacom3-Sep-04 7:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.