|
-
Dec 19th, 2001, 12:34 AM
#1
Thread Starter
Hyperactive Member
SOLVED - Problem while opening recordset
I am opening ADO.recordset object with following query
SELECT E.empName,E.basic,E.current,S.increament,S.dateOfInc FROM employeeMaster E,empSalary S WHERE S.empCode = E.empCode
But it is giving me error like
"Method 'Open' of object '_Recordset' failed"
I have checked that recordset is declared and set and query is also working.
Please help!
Last edited by abhid; Dec 19th, 2001 at 02:17 AM.
-
Dec 19th, 2001, 12:37 AM
#2
Do you have a valid connection?
-
Dec 19th, 2001, 12:41 AM
#3
Thread Starter
Hyperactive Member
of course i do..
Other recordsets are working fine.
-
Dec 19th, 2001, 01:13 AM
#4
PowerPoster
ADODB OR ADODC?
VB Code:
SELECT E.empName,E.basic,E.current,S.increament,S.dateOfInc FROM employeeMaster E,empSalary S WHERE S.empCode = E.empCode
empSalary S
Is that meant to be a space?
Do you just want all the fields?
Else:
VB Code:
SELECT E.empName & E.basic & E.current & S.increament & S.dateOfInc FROM employeeMaster E & empSalary S WHERE S.empCode = E.empCode
-
Dec 19th, 2001, 01:27 AM
#5
Thread Starter
Hyperactive Member
its ADODB.
about 'empSalary S'. Yes it is space.
i am using S as alias to empSalary table.
VB Code:
SELECT E.empName,E.basic,E.current,S.increament,S.dateOfInc FROM employeeMaster E,empSalary S WHERE S.empCode = E.empCode
this query is working properly in SQL view for MSAcces. It is returing expected no. of rows.
I checked with a simple query like 'select * from empsalary'.
It opened the recordset properly.
Problem is the query mentione above is not working with recordset.
What it could be?
Thanks for the efforts.
-
Dec 19th, 2001, 01:31 AM
#6
PowerPoster
hi
Pls. paste ur code - just before the open method - I feel there lies the prob.
-
Dec 19th, 2001, 01:38 AM
#7
Thread Starter
Hyperactive Member
it is
VB Code:
Private Sub setSalaryData()
Set rsNavigateSalaryData = New Recordset
strQuery = "SELECT E.empName,E.basic,E.current,S.increament,"_
& "S.dateOfInc FROM employeeMaster E,empSalary S WHERE " _
& "S.empCode = E.empCode"
rsNavigateSalaryData.Open strQuery,conn, adOpenKeyset, adLockOptimistic
End Sub
-
Dec 19th, 2001, 01:46 AM
#8
PowerPoster
Try:
VB Code:
Private Sub setSalaryData()
Set rsNavigateSalaryData = New ADODB.Recordset
strQuery = "SELECT E.empName,E.basic,E.current,S.increament,"_
& "S.dateOfInc FROM employeeMaster E,empSalary S WHERE " _
& "S.empCode = E.empCode"
rsNavigateSalaryData.Open strQuery,conn, adOpenKeyset, adLockOptimistic, adcmdtext
End Sub
-
Dec 19th, 2001, 01:49 AM
#9
PowerPoster
Just a check :
Is conn your connection object GLOBAL?
-
Dec 19th, 2001, 01:57 AM
#10
Thread Starter
Hyperactive Member
thanks Beacon but it still has the same problem.
and yes veryjonny, my conn object is global.
-
Dec 19th, 2001, 02:01 AM
#11
PowerPoster
Everthing looks okay .
Cant figure what could be wrong.
Just two suggestions :
1)Check after removing the cursorlocation,locktype and the cmdText thing.
2) Just change the query - use one table instead and check.
-
Dec 19th, 2001, 02:10 AM
#12
Thread Starter
Hyperactive Member
i am really frustrated
may be i should try another query.
I am working on it...
Thanks guys for your help.
-
Dec 19th, 2001, 02:16 AM
#13
Thread Starter
Hyperactive Member
hey guys i solved it. The query goes like
VB Code:
SELECT employeeMaster.empName, empSalary.increament, empSalary.dateOfInc
FROM employeeMaster INNER JOIN empSalary ON employeeMaster.empcode = empSalary.empCode
WHERE (([employeeMaster].[empcode]=[empsalary].[empcode]))
-
Dec 19th, 2001, 02:18 AM
#14
PowerPoster
I still reckon your sql's wrong!
VB Code:
Private Sub setSalaryData()
Set rsNavigateSalaryData = New ADODB.Recordset
strQuery = "SELECT E.empName,E.basic,E.current,S.increament,"_
& "S.dateOfInc FROM employeeMaster E & empSalary S WHERE " _
& "S.[empCode] = E.[empCode] ;"
rsNavigateSalaryData.Open strQuery,conn, adOpenKeyset, adLockPessimistic, adcmdtext
End Sub
Changed the lock just in case!
S and E are tables correct?
I still dont like that FROM bit though? Which ones are the tables?
-
Dec 19th, 2001, 02:19 AM
#15
PowerPoster
Oh well good!
We'd get there enventually!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|