これを解決しようとしましたが、これを行うとクレイジーなエラーが発生しますか?
ここに私の最初の方法があります --> SQLQUERY を保持します
[WebMethod]
public ArrayList getAllaEgenskaperforenmall(string mall_id)
{
ArrayList dbFetch;
// string parameter1 = "mall_namn";
string sqlReadQuery = "SELECT DISTINCT d.egenskaper_namn FROM(SELECT egen.egenskaper_id, egen.egenskaper_namn, kopp.mall_id, kopp.egenskap_id, emall.mall_id as egenskapensmallid, emall.mall_namn FROM t_egenskaper as egen, t_kopplingmallegenskaper as kopp, t_egenskapsmall as emall WHERE kopp.mall_id = 1 AND kopp.egenskap_id = egen.egenskaper_id) as d";
dbFetch = executeReadSqlQueryArray(sqlReadQuery);
return dbFetch;
}
次に、データを取得できる一般的な Web メソッドをセットアップしようとしました。
public ArrayList executeReadSqlQueryArray(string sqlToFetchData, string parameter1 = "", string parameter2 = "", string parameter3 = "")
{
SqlConnection conn = new SqlConnection(mConnectionstring);
SqlCommand command = new SqlCommand();
SqlDataReader sqlReader;
ArrayList dataReadFromDatabase = new ArrayList();
command.Connection = conn;
command.Connection.Open();
command.CommandText = sqlToFetchData;
sqlReader = command.ExecuteReader();
while(sqlReader.Read())
{
object[] values = new object[sqlReader.FieldCount];
sqlReader.GetValues(values);
dataReadFromDatabase.Add(values);
}
command.Connection.Close();
return dataReadFromDatabase;
}
私が得るエラーはこれですか?面白いことに、昨日は思い通りにできたと思います。
System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type System.Object[] 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.Write8_ArrayOfAnyType(Object o)
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayListSerializer2.Serialize(Object objectToSerialize, XmlSerializationWriter writer)
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o, XmlSerializerNamespaces namespaces)
at System.Web.Services.Protocols.XmlReturnWriter.Write(HttpResponse response, Stream outputStream, Object returnValue)
at System.Web.Services.Protocols.HttpServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream)
at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues)
at System.Web.Services.Protocols.WebServiceHandler.Invoke()