Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Oracle Number Fields returns 0.

Status
Not open for further replies.

79251

IS-IT--Management
Jun 5, 2000
17
IN
I tried ADO RS to access Oracle database, I issued the following query &quot;SELECT * FROM C_GR WHERE VCODE='00006'&quot;.<br><br>The following is the structure of the C_GR table;<br><br>PONO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CHAR(8)<br>PCODE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CHAR(10)<br>VCODE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CHAR(6)<br>ITEMSRLNO&nbsp;&nbsp;&nbsp;NUMBER(2) <br>QTYRCV&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NUMBER(6)<br><br>All the character fields I am able to get the value but when i try to access the number field like itemsrlno it show 0 in that field.<br><br>Can anybody help me how to solve this problem.<br><br>Logamoorthy
 
Logamoorthy -<br><br>Can you post your code where you're actually trying to access the field?<br><br>Chip H.<br>
 
Hi Chip H<br><br>The following is my function which loads my tree view control.<br><br>Please reply me immediately it is very urgent<br><br>'Declaration<br>Dim WithEvents RS_GR_Details As Recordset<br><br>Public Function LoadGRDetails(cVendorCode As String)<br>Dim NewNode As Node<br>Dim cKey As String<br>Dim cText As String<br>Dim cGRNo As String<br><br>&nbsp;&nbsp;&nbsp;&nbsp;On Error GoTo ConnectionError:<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;Set RS_GR_Details = New Recordset<br><br>&nbsp;&nbsp;&nbsp;&nbsp;With RS_GR_Details<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.CursorLocation = adUseClient<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.CursorType = adOpenKeyset<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.LockType = adLockOptimistic<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.CacheSize = 50<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Source = &quot;SELECT * FROM C_GR WHERE VCODE='&quot; + txtVCode.Text + &quot;' ORDER BY GRNO&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.ActiveConnection = ConString&nbsp;&nbsp;'public constant<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Open<br>&nbsp;&nbsp;&nbsp;&nbsp;End With<br><br>&nbsp;&nbsp;&nbsp;&nbsp;On Error GoTo 0<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;If RS_GR_Details.RecordCount = 0 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'no records in the vendor invoice table<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox (&quot;No GR found&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TreeView1.Nodes.Clear<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cText = txtVCode.Text<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set NewNode = TreeView1.Nodes.Add(, , &quot;Root&quot; + cText, cText, 1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cText = &quot;&quot;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RS_GR_Details.MoveFirst<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Do While Not (RS_GR_Details.EOF)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cGRNo = RS_GR_Details(&quot;GRNO&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cText = txtVCode.Text<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set NewNode = TreeView1.Nodes.Add(&quot;Root&quot; + cText, tvwChild, &quot;ChildGR&quot; + cGRNo, cGRNo, 2)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cText = &quot;&quot;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Do While cGRNo = RS_GR_Details(&quot;grno&quot;)<br><br>****** Here I am accessing &quot;QTYRCV&quot; & &quot;ITEMSRLNO&quot;, which returns zero value *****************<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cText = RS_GR_Details(&quot;vdc_no&quot;) + Space(2) + Str(RS_GR_Details(&quot;itemsrlno&quot;)) + Space(2) + Str(RS_GR_Details(&quot;qtyrcv&quot;))<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set NewNode = TreeView1.Nodes.Add(&quot;ChildGR&quot; + RS_GR_Details(&quot;grno&quot;), tvwChild, , cText, 2)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cText = &quot;&quot;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RS_GR_Details.MoveNext<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If RS_GR_Details.EOF Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit Do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Loop<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Loop<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>ConnectionError:<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;If Err.Number &lt;&gt; 0 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;Error in Connecting to the Database :&quot; & Str(Err.Number) & &quot; &quot; & Err.Description, vbCritical + vbOKOnly<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Err.Clear<br>&nbsp;&nbsp;End If<br>&nbsp;&nbsp;<br>End Function<br>
 
79251,<br><br>If you do a <FONT FACE=monospace><b>Select * From C_GR</font></b> using Sql*Plus do you get reasonable values out of the NUMBER columns? <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Yes I am able&nbsp;&nbsp;to see the values in Sql*Plus<br><br>Logamoorthy
 
What if you do something like:<br><br><FONT FACE=monospace><br>Dim lTemp as long<br><br>cText = RS_GR_Details(&quot;vdc_no&quot;) & Space(2)<br>lTemp = RS_GR_Details(&quot;itemsrlno&quot;)<br>cText = cText & str(lTemp) & Space(2)<br>lTemp = RS_GR_Details(&quot;qtyrcv&quot;)<br>cText = cText & str(lTemp)<br></font><br><br>This will do two things -- allow you to inspect each column as it's being retrieved and changing the plus mark &quot;+&quot; to use the ampersand (better for string concatenation).<br><br>Chip H.<br><br>
 
Hi Chip H<br><br>I tried your code,&nbsp;&nbsp;but it doesn't work. Please somebody try to give me solution.<br><br>Logamoorthty
 
Where does my code fail? On the first line (which reads a varchar2 value), or on the second line (which reads a number)?<br><br>Chip H.<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top