如何创建返回arraylist rom sql server的web服务asmx [英] how create web service asmx who return arraylist rom sql server
本文介绍了如何创建返回arraylist rom sql server的web服务asmx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要帮助
i想创建一个从sql server返回arraylist的web服务asmx!
i有错误System.NullReferenceException:la reference de l'objet n'est pas definie une instance de l'objet
------------------------------- ------------------
I need a help
i would like create an web service asmx who return arraylist from sql server !
i have an error System.NullReferenceException: la reference de l'objet n'est pas definie une instance de l'objet
-------------------------------------------------
<webmethod()> _
Public Function data() As ArrayList()
Dim con As New SqlConnection
con.ConnectionString = "Data Source=.;Initial Catalog=personnel;Integrated Security=True"
con.Open()
Dim Sql As String = "select Nom from Employes "
Sql = String.Format(Sql)
Dim Command As New SqlCommand(Sql, con)
Dim dr As SqlDataReader
dr = Command.ExecuteReader()
'Dim result = ""
While dr.Read()
result.Add(dr(0).ToString)
Return result.ToArray
End While
Return result.ToArray
Dim sas As String
Dim x As New web_servive_array.Web
sas = x.data(Sql).ToString
con.Close()
Return result.ToArray
End Function
----------------------------- -----------------------
请帮助
----------------------------------------------------
please help
推荐答案
首先它是VB.Net代码,所以从你的问题中删除C#标签:)。
那里抛出的异常尝试取消引用空对象引用。
有关详细信息,请参阅: https://msdn.microsoft.com/en-us/library/system.nullreferenceexception%28v=vs.110%29.aspx [ ^ ]
尝试调试代码,如果指定出现此错误的哪一行会更好。
Hi, First of all it's VB.Net code so remove C# tag from your question :).
The exception that is thrown when there is an attempt to dereference a null object reference.
For more information see this : https://msdn.microsoft.com/en-us/library/system.nullreferenceexception%28v=vs.110%29.aspx[^]
Try to debug your code and it will be better if you specify on which line you are getting this error.
这篇关于如何创建返回arraylist rom sql server的web服务asmx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文