I'm trying to use a webservice that hooks to SQL data and will need to return a multidimensional array so that I can bind the SQL data to a drop down list box. I'm able to return a single column of data(client name) and successfully bind to the drop down listbox, but I need to return 2 values(client name and number) and am not sure how to do it. The closest I have been able to get my webservice to work was when I tried using jagged arrays, but the speed was super slow(1,700 records). The speed is fast however when returning a single column array. Let me know if you have any thoughts or if you can guide me to an example of multidimensional arrays. Here is my code for the single column array:
Normal
0
false
false
false
EN-US
X-NONE
X-NONE
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"Times New Roman";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Data.SqlClient
Imports System.Data
Imports System.Xml.Serialization
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")>
_
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> <ToolboxItem(False)>
_
Public Class Service1
Inherits
System.Web.Services.WebService
<WebMethod()> Public Function
GetMyClients(ByVal AlphaCode As String) As String()
Dim connStr As String = "Server=cldb161;Database=NMTest;Trusted_Connection=False;"
Dim sqlStr As String = "select
clname, clnum from l_clntlist where clname like '" & AlphaCode
& "%' order by clname"
Dim returnString As String() = Nothing
Dim sqlConn As
SqlConnection = New SqlConnection(connStr)
Dim SqlCmd As
SqlCommand = New SqlCommand(sqlStr, sqlConn)
Dim sqlReader As
SqlDataReader
Try
sqlConn.Open()
sqlReader = SqlCmd.ExecuteReader()
ReDim Preserve
returnString(0)
Do While
sqlReader.Read
ReDim Preserve
returnString(UBound(returnString) + 1)
returnString(UBound(returnString)) = sqlReader("clname")
Loop
sqlReader.Close()
sqlConn.Close()
Catch ex As Exception
End Try
Return returnString
End
Function