473,325 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

This Code give a wrong argument pass. What else should i do?

I am quite new to VB6.0. Now am trying to create a connection to NWIND.mdb. But each time i run my program i keep getting error in "Wrong argument passed"
the below were what i wrote in my MODULE

Public cn As ADODB.Connection
Public Function dcn()
Const DBpath = "C:\program files\microsoft visual studio\vb98\nwind.mdb"
On Error GoTo err_handler

Screen.MousePointer = vbCustom
Screen.MouseIcon = LoadPicture("C:\Documents and Settings\udeme.PROGRAMMING\Desktop\Ibank4XP\Report s\Icons\settings.ico")
Set cn = New ADODB.Connection
cn.Open "provider = microsoft.jet.oledb.3.51; data source= " & DBpath
Exit Function
err_handler:
MsgBox Err.Description, vbCritical, App.Title
End Function

Public Function openrsval(ByVal pRecordsetname As String) As Recordset
Set openrsval = Openrs(pRecordsetname, adOpenStatic, adLockPessimistic)
End Function

Public Function Openrs(ByVal pRecordsetname As String, pcType As Variant, pltype As Variant) As ADODB.Recordset
On Error GoTo err_handler
Set Openrs = New ADODB.Recordset
Openrs.CursorLocation = adUseServer
Openrs.Open pRecordsetname, dcn, adOpenDynamic, adLockPessimistic

Exit Function
err_handler:
MsgBox Err.Description, vbCritical, App.Title

End Function


AND I JUST PASSED THE BELOW TO MY FORM ONLOAD
Dim rsall As Recordset
Private Sub Form_Load()
Set rsall = openrsval("Order Details")
End Sub

PLS. WHERE IS THE ERROR FROM

THANKS.
PETER
Feb 1 '07 #1
3 1405
hariharanmca
1,977 1GB
I am quite new to VB6.0. Now am trying to create a connection to NWIND.mdb. But each time i run my program i keep getting error in "Wrong argument passed"
the below were what i wrote in my MODULE

Public cn As ADODB.Connection
Public Function dcn()
Const DBpath = "C:\program files\microsoft visual studio\vb98\nwind.mdb"
On Error GoTo err_handler

Screen.MousePointer = vbCustom
Screen.MouseIcon = LoadPicture("C:\Documents and Settings\udeme.PROGRAMMING\Desktop\Ibank4XP\Report s\Icons\settings.ico")
Set cn = New ADODB.Connection
cn.Open "provider = microsoft.jet.oledb.3.51; data source= " & DBpath
Exit Function
err_handler:
MsgBox Err.Description, vbCritical, App.Title
End Function

Public Function openrsval(ByVal pRecordsetname As String) As Recordset
Set openrsval = Openrs(pRecordsetname, adOpenStatic, adLockPessimistic)
End Function

Public Function Openrs(ByVal pRecordsetname As String, pcType As Variant, pltype As Variant) As ADODB.Recordset
On Error GoTo err_handler
Set Openrs = New ADODB.Recordset
Openrs.CursorLocation = adUseServer
Openrs.Open pRecordsetname, dcn, adOpenDynamic, adLockPessimistic

Exit Function
err_handler:
MsgBox Err.Description, vbCritical, App.Title

End Function


AND I JUST PASSED THE BELOW TO MY FORM ONLOAD
Dim rsall As Recordset
Private Sub Form_Load()
Set rsall = openrsval("Order Details")
End Sub

PLS. WHERE IS THE ERROR FROM

THANKS.
PETER

did you specify any User name or password to your DB?
Feb 1 '07 #2
Killer42
8,435 Expert 8TB
You really need to give us more detail on when/where the error is detected. For starters, try commenting out the On Error statement so that the error is reported as soon as it happens, rather than going to your error-handling code.

You can also try stepping through the code one statement at a time to see where it is having trouble. Once we know which statement has the problem, then we can start digging into why.
Feb 2 '07 #3
Dököll
2,364 Expert 2GB
Indeed, stepping through it is the key here, live saver really:

(1) Before you run your code
(2) Go to Debug
(3) Choose 'Step into'
(4) Use F8 to see what the code is doing

TIP #1: If you want go to View, and select Locals Window, that'll allow you to see additional info on thecode running

TIP #2: You should truly consider, as mentioned here, getting rid of the default error handling in your code, you need to see all errors as they happens.

Good luck!
Feb 2 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: atv | last post by:
Hi, is there something wrong with this code? It seems that it crashes at the else { clause, when allocating a second record. Excuse for the indentation, the g_warnings are from gtk. Also, i'm...
14
by: code break | last post by:
what is the difference in this pointers decalarition ? int *ptr; and int (*ptr);
4
by: robinsand | last post by:
Header File: car.h #if !defined CAR_H #define CAR_H enum TCarType { ctEconomy = 1, ctCompact, ctStandard, ctFullSize, ctMiniVan, ctSUV }; class Car { public: Car();
28
by: H J van Rooyen | last post by:
Hi, I want to write a small system that is transaction based. I want to split the GUI front end data entry away from the file handling and record keeping. Now it seems almost trivially easy...
171
by: Raman | last post by:
Hi All, Here is a small Code, int main(void) { char *p=(char *) malloc(100); strcpy(p,"Test1234567890"); p=p+10; free(p);
83
by: Anonymous | last post by:
Came across some code summarized as follows: char const* MyClass::errToText(int err) const { switch (err) { case 0: return "No error"; case 1: return "Not enough"; case 2: return "Too...
11
by: Daniel T. | last post by:
The function below does exactly what I want it to (there is a main to test it as well.) However, I'm curious about ideas of making it better. Anyone interested in critiquing it? void formatText(...
9
by: xiao | last post by:
It always dumped when I tried to run it... But it compiles OK. What I want to do is to do a test: Read information from a .dat file and then write it to another file. The original DAT file is...
5
by: Shalini Bhalla | last post by:
hi , A strange error is coming , when i run a php file , all the php and java script executes before submit only which actually should execute after clicking on submit button and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shćllîpôpď 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.