Hi,
I've been pulling my hair out over a problem and I'm sure its my lack of experience and probably easily answered. I've done a lot of searching but I'm probably not clued up enough to know what I'm actually looking for.
I'm creating an XML web service, which is reading data from a MySQL database. I just cant seem to get the value from the database into Class for the xml - keep getting direct cast errors (which I dont understand)or when I try a different way I'm now getting "Value of type 'String' cannot be converted to Soap.Topic"
Here's relevant bits of my code, please help!
I've been pulling my hair out over a problem and I'm sure its my lack of experience and probably easily answered. I've done a lot of searching but I'm probably not clued up enough to know what I'm actually looking for.
I'm creating an XML web service, which is reading data from a MySQL database. I just cant seem to get the value from the database into Class for the xml - keep getting direct cast errors (which I dont understand)or when I try a different way I'm now getting "Value of type 'String' cannot be converted to Soap.Topic"
Here's relevant bits of my code, please help!
Code:
<WebMethod()> _
Public Function Categories() As Topics
Dim CG As New Topics
Dim Temp As New ArrayList
Dim count As Integer = 0
SQLConnection.ConnectionString = ServerString
Try
If SQLConnection.State = ConnectionState.Closed Then
strQuery = "SELECT categories.Name " & _
"FROM categories"
SQLCmd = New MySqlCommand(strQuery, SQLConnection)
SQLConnection.Open()
DR = SQLCmd.ExecuteReader
Do While (DR.Read())
Temp.Add(DR.Item("name"))
Loop
count = 0
For Each dato As String In Temp
CG.Category(count) = dato
count = count + 1
Next
CG.Result = ("Successfully read")
DR.Close()
SQLConnection.Close()
Else
SQLConnection.Close()
Result = ("Connection is Closed.")
End If
Catch ex As Exception
CG.Result = (ex.ToString)
End Try
Return CG
End Function
Public Class Topics
Public Category() As Topic
Public Result As String
End Class
Public Class Topic
Public Top As String
End Class
Comment