471,350 Members | 1,586 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

AJAX-AutoComplete Oracle VB.NET

7
I am having problems using the ajax autocomplete. I actually think it may be an Oracle problem not autocomplete problem because I can get the autocomplete working without searching the database for like values. Here is my code:
Expand|Select|Wrap|Line Numbers
  1. Imports System
  2. Imports System.IO
  3. Imports System.Web
  4. Imports System.Web.Services
  5. Imports System.Web.Services.Protocols
  6. Imports System.Collections
  7. Imports System.Collections.Generic
  8. Imports System.Threading
  9. Imports System.Xml.Serialization
  10. Imports System.Data.Common
  11. Imports System.Data              ' VB.NET
  12. Imports Oracle.DataAccess.Client
  13.  
  14. <WebService(Namespace:="http://tempuri.org/")> _
  15. <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
  16. <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
  17. <System.Web.Script.Services.ScriptService()> _
  18. Public Class AutoCompleteDAL
  19.     Inherits System.Web.Services.WebService
  20.     Public Shared autoCompleteWordList As String()
  21.  
  22.  
  23.     <WebMethod()> _
  24.     Public Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer) As String()
  25.  
  26.         Dim Sql As String = "SELECT NAME from NAMELIST WHERE NAME  LIKE '" & prefixText & "' || '%' ORDER BY NAME ;"
  27.         Dim Conn As New _
  28.                OracleClient.OracleConnection(ConfigurationManager.ConnectionStrings( _
  29.               "OrdConnectionString").ConnectionString)
  30.         ' Dim Conn As OracleConnection = New OracleConnection("Data Source=dbHazard;User ID=HazUser;Password=password")
  31.         '  Dim cmd As New OracleCommand(Sql, Conn)
  32.         Dim cmd As New OracleClient.OracleCommand(Sql, Conn)
  33.         Dim items As New List(Of String)
  34.         Dim dr As OracleClient.OracleDataReader = cmd.ExecuteReader() ' VB.NET
  35.         While dr.Read() ' VB.NET
  36.             items.Add(dr.Item("NAME"))
  37.         End While
  38.  
  39.         'items.Add(dr.Item("NAME"))
  40.         Return items.ToArray
  41.  
  42.  
  43.  
  44.     End Function
  45.  
  46.  
  47. End Class
  48.  
Any assistance would be greatly appreciated. Thanks.
Jul 9 '07 #1
10 3792
Frinavale
9,735 Expert Mod 8TB
Welcome to TSDN :) I hope you like it here!

What is the error message you're getting?
If there's no error message, could you better explain what is happening?
Have you tried returning a clone of your items array?

Thanks,
-Frinny
Jul 9 '07 #2
kym
7
I do like it here! I have been searching the site for awhile but this is the first time I posted anything. I am not getting an error. I am not getting anything at all. Thanks. The autocomplete works when I am not using the Oracle datareader. It does nothing when insert in the oracle stuff. Thanks.



<asp:TextBox ID="txtNAME" runat="server" MaxLength="5"></asp:TextBox>
<ajaxtoolkit:AutoCompleteExtender ID="AutoCompleteExtender1"
TargetControlID="txtNAME" Enabled="True" ServicePath="AutoComplete.asmx"
ServiceMethod="GetCompletionList" MinimumPrefixLength="0" runat="server" FirstRowSelected="true" >

</ajaxtoolkit:AutoCompleteExtender>
Jul 10 '07 #3
kym
7
Have you tried returning a clone of your items array? No, not sure what this is. I am new to both vb.net and oracle.
Jul 10 '07 #4
Frinavale
9,735 Expert Mod 8TB
You should close your data reader when you are done with it to clean things up.
Could you possibly post the code for where you are assigning your "items" array to the control using the auto complete?

Have you tried declaring your items array like this:
Expand|Select|Wrap|Line Numbers
  1. Dim items() As New String
  2.  
Instead of like this:
Expand|Select|Wrap|Line Numbers
  1. Dim items As New List(Of String)
  2.  
I don't think you'll need to use items.ToArray in your return statement if you change your declaration...I wonder if something might be going wrong there?

-Frinny
Jul 10 '07 #5
kym
7
You should close your data reader when you are done with it to clean things up.
Could you possibly post the code for where you are assigning your "items" array to the control using the auto complete?

Have you tried declaring your items array like this:
Expand|Select|Wrap|Line Numbers
  1. Dim items() As New String
  2.  
Instead of like this:
Expand|Select|Wrap|Line Numbers
  1. Dim items As New List(Of String)
  2.  
I don't think you'll need to use items.ToArray in your return statement if you change your declaration...I wonder if something might be going wrong there?

-Frinny



I tried this and got the following error:Value of type 'String' cannot be converted to '1-dimensional array of String'.

Thanks again.
Jul 10 '07 #6
Frinavale
9,735 Expert Mod 8TB
I tried this and got the following error:Value of type 'String' cannot be converted to '1-dimensional array of String'.

Thanks again.
You need to specify a length for the Array...
Sorry I guess I wasn't thinking clearly earlier..I've just never used a List before.
I just looked it up and it looks like you're doing things correctly.

Earlier, did you mean to say that everything worked properly when you added items to the List manually..and then returned the toArray() version of this list to your calling function?
Jul 10 '07 #7
kym
7
The problem occurs because for some reason it exits the function on the following **** statement:
Expand|Select|Wrap|Line Numbers
  1.   <WebMethod()> _
  2.     Public Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer) As String()
  3.  
  4.         Dim Sql As String = "SELECT NAME from NAMELIST WHERE NAME  LIKE '" & prefixText & "' || '%' ORDER BY NAME ;"
  5.         Dim Conn As New _
  6.                OracleClient.OracleConnection(ConfigurationManager  .ConnectionStrings( _
  7.               "OrdConnectionString").ConnectionString)
  8.         ' Dim Conn As OracleConnection = New OracleConnection("Data Source=dbHazard;User ID=HazUser;Password=password")
  9.         Dim cmd As New OracleClient.OracleCommand(Sql, Conn)
  10.         Dim items As New List(Of String)
  11.   '****(exits on the following line)
  12.       Dim dr As OracleClient.OracleDataReader = cmd.ExecuteReader() ' VB.NET
  13.         While dr.Read() ' VB.NET
  14.             items.Add(dr.Item("NAME"))
  15.         End While
  16.  
  17.         'items.Add(dr.Item("NAME"))
  18.         Return items.ToArray
  19.  
  20.  
  21.  
  22.     End Function
Jul 17 '07 #8
kym
7
For some reason it is my connection string
Jul 23 '07 #9
kym
7
For anyone that needs to know, you can not use ; in sql statement with autocomplete this will cause an error. thanks for help.
Jul 24 '07 #10
Frinavale
9,735 Expert Mod 8TB
For anyone that needs to know, you can not use ; in sql statement with autocomplete this will cause an error. thanks for help.

Thanks for sharing the solution!

:D
Jul 24 '07 #11

Post your reply

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

Similar topics

11 posts views Thread by Yarco | last post: by
4 posts views Thread by bobzimuta | last post: by
reply views Thread by melledge | last post: by
1 post views Thread by www.web20developers.com | last post: by
10 posts views Thread by =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post: by
2 posts views Thread by soni2926 | last post: by
11 posts views Thread by =?Utf-8?B?R2VyaGFyZA==?= | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.