Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 26-08-2008, 03:32 PM   #1 (permalink)
Alpha Geek
 
saurabh.sauron's Avatar
 
Join Date: Jan 2006
Location: Middle Earth
Posts: 503
Default VB 6 Query


I am facing problems in connecting VB To Oracle. Here is the code that i have used

Code:
Public Sub Conn()
Dim cn As New ADODB.Connection
Dim constr As String
Set cn = New ADODB.Connection
constr = "Provider=MSDAORA.1;user id=scott;password=tiger"
cn.Open constr
End Sub
Code:
Dim rs As New ADODB.Recordset
Dim sqlstr As String

Private Sub Command1_Click()
Call Module1.Conn
rs.CursorLocation = adUseClient
strsql = "Select * from users;"
rs.Open strsql, cn, adOpenDynamic, adLockOptimistic, adCmdText
If cn.State = adStateOpen Then
MsgBox "Open"
Else: MsgBox "Closed"
End If
End Sub
The Error:
Run Time Error 3001.
Arguments are of wrong type, unacceptable range or are in conflict with one another.

pls help
thnx
saurabh.sauron is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 01-09-2008, 03:52 PM   #2 (permalink)
javed4shab
Guest
 
Posts: n/a
Thumbs up Re: VB 6 Query

Hi Boss,
use this code instead, I've designed this code, This works best on any platform.


Dim con as new adodb.connection
dim rs as new adodb.recordset
Private sub form_load()
set con = new adodb.connection
with con
.connectionstring = "Provider= MSDAORA; User id=scott; password=tiger"
.connectiontimeout = 5
.cursor location = aduseclient
.open
end with
end sub


Javed Khan
 
Old 07-09-2008, 03:07 PM   #3 (permalink)
javed4shab
Guest
 
Posts: n/a
Wink Re: VB 6 Query

Boss,

As I've already informed, Just use the Code I've Provided, it will work best for you.

Apart from this if you wish to do code to retrieve data just use:

Prrivate Sub cmdok_click()
set rs = new adodb.recordset
rs.open "select * from emp", con, adlockoptimistic, adopendynamic, adcmdtext
set datagrid1.datasource = rs.datasource

end sub

Just use "set datagrid1.datasource = rs.datasource" after every update to update the data grid.

also remember, recordset and connection variables, ie rs and con should be declared on module level.

to get data from any text box just type:

rs!empno = text1.text

Enjoy!

Javed Khan
 
Old 20-09-2008, 09:33 PM   #4 (permalink)
Right Off the Assembly Line
 
Join Date: Sep 2008
Posts: 3
Default Re: VB 6 Query

The best way to handle Oracle and VB Database Connection is to Use ADODC and not ADODB if you have to use ADODB then copy and paste the ADODC code that is automatically generated by VB (incase your assignment reques it)
abhijeet.k1810 is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SLI Query? sabret00the Hardware Q&A 27 12-08-2007 04:40 PM
c2d query ramana321388 QnA (read only) 8 09-10-2006 08:25 PM
DVD-RW query thecyclone2k Hardware Q&A 26 29-07-2006 01:00 PM
UPS Query ! ! kaps_2222 Hardware Q&A 5 07-11-2005 10:54 PM
Microtek Monitor Query and PHPBB Attachment Mod Query vwad Software Q&A 1 20-03-2005 09:32 AM

 
Latest Threads
- by Sujeet
- by clmlbx
- by Sujeet
- by icebags

Advertisement




All times are GMT +5.5. The time now is 11:11 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2