Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Ques regarding VB ADO recordset with oracle8i


Message #1 by "Neeraj sharma" <nsharma@a...> on Fri, 13 Oct 2000 18:01:42 +0100
Hi Neeraj,

The server name with Microsoft ODBC for Oracle should be the service name
for your database (usually the global database name). The ODBC connection
string would look like this:

Provider=MSDASQL;DRIVER={Microsoft ODBC for Oracle};SERVER=<service
name>;UID=SYSTEM;PWD=manager;

Cheers,
Julian

Julian Skinner
Technical Architect
Wrox Press
http://www.wrox.com
julians@w...


-----Original Message-----
From: Neeraj sharma [mailto:nsharma@a...]
Sent: 13 October 2000 18:02
To: professional vb
Subject: [pro_vb] Ques regarding VB ADO recordset with oracle8i


Hi
My name is Neeraj sharma and i am a software developer.I am going thru
Wrox ' book PROFESSIONAL VB6 DATABASES by CHARLES WILLIAMS.
I m facing peculiar problem.
I am using VB6.0 as a front end and Oracle 8i(loaded on my local machine)
as the backend .
I made a System DSN using Oracle ODBC Driver from the control
panel.thereafter used ADO 2.0 recordset object to fetch records.
Surprisingly i can fetch the varchar or char fields very fine but all
columns with NUMBER datatype r converted into NULL in the recordset.
even more surprising is the fact that i can insert or update the records
thru the same connection and it works PERFECTLY for both numeric and char
datatypes!!!
Its only while fetching records that only the numeric datatypes r
converted to NULL.
NOTE : THE MOST SURPRISING THING THAT THE CODE WORKS BEAUTIFULLY WITH
PERSONAL ORACLE 7.3 ,through a DSN MADE WITH DRIVER ORACLE73.


I also tried to make a DSN with MicrosoftODBC for oracle driver.but it
asks me for a server name.i m working on a standalone machine with oracle
installed on it .OS is windows NT 4.0 workstation.
what should i type in the server text box pl give me the exact syntax.

also if possible tell me what should i give in the connectionstring of the
connection object if i want to make a DSN less connection between VB and
oracle .pl send the EXACT syntax.

i m copying the sample VB project code  for ur viewing.
hoping to hear from u soon.
thanks


Dim objconn As ADODB.Connection
Dim objcomm As ADODB.Command
Dim objrec As ADODB.Recordset

Private Sub Form_Load()
Set objconn = New ADODB.Connection
objconn.ConnectionString = "DSN=neerajtest;UID=SYSTEM;PWD=manager;"
objconn.Open
Set objcomm = New ADODB.Command
objcomm.ActiveConnection = objconn
objcomm.CommandText = "insert into neeraj_emp
values('sambhav3','Secunderabad','20',10000)"  'works fine while INSERTING
numeric values
objcomm.CommandType = adCmdText
Dim lngrecs As Integer
objcomm.Execute lngrecs
MsgBox lngrecs & "Records inserted"
objconn.Close
End Sub

Private Sub Command1_Click()
Set objconn = New ADODB.Connection
Set objcomm = New ADODB.Command
objconn.ConnectionString = "DSN=neerajtest;UID=SYSTEM;PWD=manager;"
objconn.Open
objcomm.ActiveConnection = objconn
objcomm.CommandText = "select * from neeraj_emp"
Set objrec = New ADODB.Recordset
objrec.LockType = adLockOptimistic
 Set objrec = objcomm.Execute
Dim sal As String

'sal = objrec.Fields("Salary") ': this is the numeric field that gives
NULL
'MsgBox objrec.Fields("salary")'obviously gives an error stating invalid
use of NULL since salary is passed as NULL into the recordset.
    For i = 0 To 3
        MsgBox objrec.Fields(i) ' Note that objrec.fields(3) is SALARY
i.e. a numeric field .the code displays name,address and dept no. i.e
i=0,1,2 resp but gives error on i=4
    Next
  
objrec.Close
objconn.Close


End Sub


  Return to Index