Hi all
am having the following problem between my asp frontend and the web server back end:
Now my database code is correct, the problem arises when I go to send the data back to the frontend. Here is my code for the backend:
And here is my frontend code:
Would appreciate any suggestions.
Mike55
am having the following problem between my asp frontend and the web server back end:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type System.String[] may not be used in this context. at System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String name, String ns, Object o, Boolean xsiType) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write1_Object(String n, String ns, Object o, Boolean isNullable, Boolean needType) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write11_wsCustomer_viewCustomerDataResponse(Object[] p) --- End of inner exception stack trace --- at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle) at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces) at System.Web.Services.Protocols.SoapServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream) at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues) at System.Web.Services.Protocols.WebServiceHandler.Invoke() --- End of inner exception stack trace ---
Now my database code is correct, the problem arises when I go to send the data back to the frontend. Here is my code for the backend:
Code:
Imports System
Imports System.Data
Imports System.Data.SqlClient
<WebMethod(Description:="View data on a customer.")> _
Public Function wsCustomer_viewCustomerData(ByVal customerName As String)
Try
Dim daDataAdapter As New SqlDataAdapter
Dim dsDataset As New DataSet
Dim returnData(11) As String
result = False
'Open the connection
conSQL = SQLConnection.connectSQL()
conSQL.Open()
'Execute the statement
commSQL.Connection = conSQL
commSQL.CommandType = CommandType.Text
'Construct the SQL command & Execute
commSQL.CommandText = "Select CustomerRef, CustomerName, CustomerType, Address, County, Phone, Fax, Email, MinCallRate, MaxCallRate, Comments from Customers where CustomerName = '" + CustomerName + "' and status = 1"
drDataReader = commSQL.ExecuteReader
While (drDataReader.Read())
returnData(0) = drDataReader.GetSqlInt32(0).ToString 'ref
returnData(1) = drDataReader.GetString(1) 'name
returnData(2) = drDataReader.GetString(2) 'type
returnData(3) = drDataReader.GetString(3) 'address
returnData(4) = drDataReader.GetString(4) 'county
returnData(5) = drDataReader.GetString(5) 'phone
returnData(6) = drDataReader.GetString(6) 'fax
returnData(7) = drDataReader.GetString(7) 'Email
returnData(8) = drDataReader.GetString(8) 'MinCallRate
returnData(9) = drDataReader.GetString(9) 'MaxCallRate()
returnData(10) = drDataReader.GetString(10) 'Comments
End While
drDataReader.Close()
conSQL.Close()
Return returnData
Catch ex As Exception
conSQL.Close()
Throw ex
End Try
End Function
And here is my frontend code:
Code:
'Get the data
Dim returnData(11) As String
returnData = wsCustomer.wsCustomer_viewCustomerData(ddCustomers.SelectedValue.ToString.Replace("'", "`"))
lblRef.Text = returnData(0)
txtName.Text = returnData(1)
ddCustomerType.SelectedItem.Text = returnData(2)
txtAddress.Text = returnData(3)
txtCounty.Text = returnData(4)
txtPhone.Text = returnData(5)
txtFax.Text = returnData(6)
txtEmail.Text = returnData(7)
txtMinCallRate.Text = returnData(8)
txtMaxCallRate.Text = returnData(9)
txtComments.Text = returnData(10)
Would appreciate any suggestions.
Mike55