|
Hi there,
I've just wrote my first webservice with VB.NET. If I want to get back strings or integers as return values everything works fine, but when I try to get an array back, there is something wrong. Maybe you can take a look at the code:
Public Class DirectoryInformation<br />
Public Name As String<br />
End Class<br />
<WebMethod()> _<br />
Public Function fncGetAllFilebin(ByVal VirtualPath As String)<br />
Dim di As New DirectoryInfo(WebServerPath & VirtualPath)<br />
Dim diArr As DirectoryInfo() = di.GetDirectories<br />
Dim dri As DirectoryInfo<br />
Dim x As Integer = 0<br />
Dim Arr As DirectoryInformation()<br />
ReDim Preserve Arr(di.GetDirectories.Length - 1)<br />
For Each dri In diArr<br />
Arr(x) = New DirectoryInformation()<br />
Arr(x).Name = dri.Name<br />
x += 1<br />
Next<br />
Return Arr<br />
End Function
The error i get is:
"System.Web.Services.Protocols.SoapException" ist in System.Web.Services.dll
System.Web.Services.Protocols.SoapException: Die Anforderung konnte vom Server nicht verarbeitet werden. ---> System.InvalidOperationException: Beim Generieren des XML-Dokuments ist ein Fehler aufgetreten. ---> System.InvalidOperationException: Der Typ whsEasyDoc.Service1+DirectoryInformation[] kann in diesem Kontext nicht verwendet werden.
bei System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String name, String ns, Object o, Boolean xsiType)
bei Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write1_Object(String n, String ns, Object o, Boolean isNullable, Boolean needType)
bei Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write8_fncGetAllFilebinResponse(Object[] p)
bei Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer13.Serialize(Object objectToSerialize, XmlSerializationWriter writer)
bei System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
--- Ende der internen Ausnahmestapelüberwachung ---
bei System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
bei System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle)
bei System.Web.Services.Protocols.SoapServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream)
bei System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues)
bei System.Web.Services.Protocols.WebServiceHandler.Invoke()
--- Ende der internen Ausnahmestapelüberwachung ---
Thanks,
Christoph
|
|
|
|
|
My German isn't very good, but I am pretty sure your problem has to do with what you are trying to return. In general you can return specific types from a webservice if they are properly defined there. Otherwise a web service only returns standard types like Int32, String, Boolean and a DataSet. So I would suggest perhaps you change your array into a DataSet and I think your error will go away.
Hope that helps.
Ben
|
|
|
|
|
Thanks Ben,
I've tried the DataSet and it works fine for me.
See you
Christoph
|
|
|
|
|
hi All the Following code reside on my Search Button.i want to search the results in datagrid(dataset),using the input from a textbox. and return the results if found. am usng SQl. here is the code i tried write , please help me fix this .
'Open Database Connection
Dim strconnection As String = "workstation id=5875-049;packet size=4096;user id=***; Password=******;data source=S*******;persist security info=False;initial catalog=Tshwane_Valuations"
Dim cn As SqlConnection = New SqlConnection(strconnection)
cn.Open()
'set up data adapter
Dim strSql As String = _
"select Actual_Extent,Attrib_code,Lis_key,Func_key,Density," _
& "New_Net_Usable_Extent,New_Total_Land_Factor,New_AdJ_Extent_1,New_Points_1," _
& "New_ADJ_Extent_2, New_Points_2, LS_Prediction, LS_Confidence,LS_TYPE from Property_Mass "
Dim da As SqlDataAdapter = New SqlDataAdapter(strSql, cn)
'load Dataset
Dim ds As DataSet = New DataSet
da.Fill(ds, "Property_Summary")
'Set up a new Data adapter Object
strSql = "select Property_Mass.Actual_Extent,Property_Mass.Attrib_code,Property_Mass.Lis_key,Property_Mass.Func_key,Property_Mass.Density," _
& " Property_Mass.New_Net_Usable_Extent,Property_Mass.New_Total_Land_Factor,Property_Mass.New_AdJ_Extent_1, Property_Mass.New_Points_1," _
& " Property_Mass.New_ADJ_Extent_2, Property_Mass.New_Points_2, Property_Mass.LS_Prediction, Property_Mass.LS_Confidence, Property_Mass.LS_TYPE," _
& " Property_Summary.Purchase_Date, Property_Summary.Purchase_Price" _
& " from Property_Mass, Property_Summary" _
& "where Substring(Lis_key,1,4)= ?"
da.SelectCommand.Parameters("Lis_key").Value = txtliskeysearch.Text
da.Fill(ds)
If ds.Tables("Property_Mass").Rows.Count = 0 Then
MessageBox.Show("Township not Found")
End If
End Sub
When i run this code it gives me an Error
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll
Additional information: An SqlParameter with ParameterName 'Lis_key' is not contained by this SqlParameterCollection.
And points to the Following line
da.SelectCommand.Parameters("Lis_key").Value = txtliskeysearch.Text
Help
Thanks
Thanks
Vuyiswa Maseko
|
|
|
|
|
|
Hi,
I am still working with VB.NET 1.1.
I have the following in my page load:
Private Sub Page_Load
If Not Page.IsPostBack Then
ViewState("ContainsSearch") = "Text 1"
End If
Response.Write("ViewState(ContainsSearch) = " & ViewState("ContainsSearch"))
End Sub
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnSearch.Click
ViewState("ContainsSearch") = "Text 2"
End Sub
When the page loads for the first time it displays Text 1. When I click the button it still displays Text 1. When I press F5, then it only displays Text 2. How can I get it to display Text 2 when I click the button because the view state value is supposed to change when I click the button.
Regards,
ma se
|
|
|
|
|
I'm no ASP.NET expert, and this question belongs in the ASP.NET forum, not the VB.NET or C# forums, but...
ViewState is a property bag for server controls acrossed page requests. This is where controls store their values when they need to be retrieved by the next request of the page. Though, I have no idea if it'll work for a Form like you're trying to use it.
|
|
|
|
|
hi everyone
i needed to write xml as follows
<employee>
<empcode>100</empcode>
<name>bb</name>
<hobbies>
<data>reading</data>
<data>listening music</data>
</hobbies>
</employee>
my employee database table is seperate and hobbeis table is separate and
they are related by emp_code which acts as a foreign key in other table
so using writexml method i need to write from the adapter.
i think i needed to do some changes in joining the table
if u have a idea how to do please explain
|
|
|
|
|
You'll have to write the code to serialize this yourself. The standard serializer will treat each table seperatly and not embed the data from one table into the rows of the other.
|
|
|
|
|
Hi,
I have two questions:
a) How can you prevent an MDI parent form from displaying scroll bars?
b) I am using a webbrowser control which is supposed to carry out a few actions once the document has been loaded and displayed. I am writing the code in the Document_Completed event but to my surprise, it carries it out before the document has been displayed (I am actually trying to take a screenshot of the loaded page, and it ends up taking it before it has completly loaded :S). Any Ideas?
Thanks,
Ahmad
|
|
|
|
|
Ahmad Zaidi wrote: a) How can you prevent an MDI parent form from displaying scroll bars?
You can't. The scroll bars will appear any time a child window extends beyond the border of the MDIParent's MdiChild control. There is no way to turn them off.
Ahmad Zaidi wrote: b) I am using a webbrowser control which is supposed to carry out a few actions once the document has been loaded and displayed. I am writing the code in the Document_Completed event but to my surprise, it carries it out before the document has been displayed (I am actually trying to take a screenshot of the loaded page, and it ends up taking it before it has completly loaded :S). Any Ideas?
The WebBrowserDocumentCompleted event will fire for each and every document that is loaded by the page. Most sites are made up of multiple documents, not just one, because of Frames. Say you have a document with 3 frames, a top site title, navigation on the left, and a content frame taking up the rest. You'll get the Document Completed event fired at least(!) 4 times. Once for the page that defines all three frames, and once for each frame in that page.
Take a look at the URL property of the WebBrowserDocumentCompletedEventArgs for which page that event is being fired for.
|
|
|
|
|
|
hi everyone
i have given the table mappings for my dataset and database table.
i needed the query for the 4 insert,delete,update and select commands
of the dataadapter.
eg) take a table employee_hobbies haveing emp_code and emp_hobbies as coloumns
i think we should use some rowstateversion.original and current
please give me the query
|
|
|
|
|
Seriously - learning to help your self know will save loads of time in the future - just google this it is simple:
As I am in a good mood here is a good start
http://www.w3schools.com/sql/default.asp
but try working things out for yourself otherwise you wont get this off the ground.
Dan
|
|
|
|
|
hi all
i need to use the ruler control as it in word
i use it to set the page margin
but i don't know how to make the slider on the ruler control and how to use it some one help me plz
bye
|
|
|
|
|
hi all
i need to print the contents of rich text box
what can i do it
thnx
|
|
|
|
|
|
How to set coloum size/width in Datagrid (Desktop Application)
A.Sutendar Reddy
asreddynet@yahoo.co.in
|
|
|
|
|
by using the datagrid property "column.width"
|
|
|
|
|
Pl. Can you send that code for disktop Application
|
|
|
|
|
|
can someone please help me about subreport...
i didnt know if it is possible -- i am thinking of creating a subreport which is accepting parameters from the main report.
ifnot-- can you just guve me a tutorial on using subreports.
another one is how could i use the "record number" that is resetting every page..
this what happens. i have a report contains lot of pages... if the first page has the number 1-8, then the other page will start on 9 and so on... which should start with 1.
thanx!
|
|
|
|
|
i have the Following code, it game an Error when i tried to run it without trapping the Error. now i used an error trap and the message i get from it now is
Line1 Incorect Syntax Near ')'
Please Help me to point the exact line where it occured. Heere is my code i have in my form load thanks.
Dim strErrorMsg As String<br />
Dim strerror As System.Data.SqlClient.SqlError<br />
<br />
Dim strconnection As String = "packet size=4096;user id=#######; Password=#########;data source=#######;persist security info=False;initial catalog=Tshwane_Valuations"<br />
Dim cn As SqlConnection = New SqlConnection(strconnection)<br />
cn.Open()<br />
<br />
'set up the data soruce <br />
Dim strSql As String = _<br />
"select Actual_Extent,Attrib_code,Lis_key,Func_key,Density," _<br />
& "New_Net_Usable_Extent,New_Total_Land_Factor,New_AdJ_Extent_1, New_Points_1, " _<br />
& "New_ADJ_Extent_2, New_Points_2, LS_Prediction, LS_Confidence from Property_Mass "<br />
Dim da As SqlDataAdapter = New SqlDataAdapter(strSql, cn)<br />
<br />
'load a Dataset <br />
Dim ds As DataSet = New DataSet<br />
da.Fill(ds, "Property_mass")<br />
<br />
'set up a new data adapter object <br />
strSql = _<br />
"select Property_Mass.Actual_Extent,Property_Mass.Attrib_code,Property_Mass.Lis_key,Property_Mass.Func_key,Property_Mass.Density," _<br />
& "Property_Mass.New_Net_Usable_Extent,Property_Mass.New_Total_Land_Factor, Property_Mass.New_AdJ_Extent_1, Property_Mass.New_Points_1," _<br />
& "Property_Mass.New_ADJ_Extent_2, Property_Mass.New_Points_2, Property_Mass.LS_Prediction, Property_Mass.LS_Confidence, Property_Mass.LS_TYPE," _<br />
& "Property_Summary.Purchase_Date, Property_Summary.Purchase_Price)" _<br />
& "from(Property_Mass, Property_Summary)" _<br />
& " where Property_Mass.Lis_key = Property_Summary.Lis_key"<br />
da = New SqlDataAdapter(strSql, cn)<br />
<br />
'load the Data set<br />
Try<br />
da.Fill(ds, "Property_Summary")<br />
'Close the Connection<br />
cn.Close()<br />
<br />
'Create relations <br />
ds.Relations.Add("Property_summary_Mass", _<br />
ds.Tables("Property_Mass").Columns("Lis_key"), _<br />
ds.Tables("Property_Summary").Columns("Lis_key"))<br />
<br />
'Bind the data set to the grid.<br />
'Assumes that Grid contains a reference to a <br />
'system.windows.datagrid<br />
DataGrid2.SetDataBinding(ds, "Property_Mass")<br />
Catch ExSQL As System.Data.SqlClient.SqlException<br />
'''All this will trap all data Problems and Network if available<br />
For Each strerror In ExSQL.Errors<br />
Next<br />
Select Case strerror.Number<br />
Case 17<br />
strErrorMsg = "Missing server"<br />
Case 4060<br />
strErrorMsg = "Missing database"<br />
Case 18456<br />
strErrorMsg = "Missing user name or password"<br />
Case Else<br />
strErrorMsg = strerror.Message<br />
End Select<br />
MessageBox.Show(strErrorMsg, "SQL Server Error: " & strerror.Number, MessageBoxButtons.OK, MessageBoxIcon.Error)<br />
<br />
Catch ExcpInvOp As System.InvalidOperationException<br />
<br />
MessageBox.Show("Close the connection first!", "Invalid Operation", MessageBoxButtons.OK, MessageBoxIcon.Error)<br />
<br />
Catch Excp As System.Exception ' generic exception handler<br />
<br />
MessageBox.Show(Excp.Message, "Unexpected Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)<br />
End Try<br />
End Sub<br />
<br />
NOTE: The username, password, and my server are corrrect i have hid them for security purpose. Thanks
Vuyiswa Maseko
|
|
|
|
|
i have seen some few stupid mistakes i have done, and i fixed it to this
<br />
Dim strErrorMsg As String<br />
Dim strerror As System.Data.SqlClient.SqlError<br />
<br />
Dim strconnection As String = "workstation id=5875-049;packet size=4096;user id=sde; Password=#####;data source=#######;persist security info=False;initial catalog=Tshwane_Valuations"<br />
Dim cn As SqlConnection = New SqlConnection(strconnection)<br />
cn.Open()<br />
'set up the data soruce <br />
Dim strSql As String = _<br />
"select Actual_Extent,Attrib_code,Lis_key,Func_key,Density," _<br />
& "New_Net_Usable_Extent,New_Total_Land_Factor,New_AdJ_Extent_1,New_Points_1," _<br />
& "New_ADJ_Extent_2, New_Points_2, LS_Prediction, LS_Confidence from Property_Mass "<br />
Dim da As SqlDataAdapter = New SqlDataAdapter(strSql, cn)<br />
<br />
'load a Dataset <br />
Dim ds As DataSet = New DataSet<br />
da.Fill(ds, "Property_mass")<br />
<br />
'set up a new data adapter object <br />
strSql = _<br />
"select Property_Mass.Actual_Extent,Property_Mass.Attrib_code,Property_Mass.Lis_key,Property_Mass.Func_key,Property_Mass.Density," _<br />
& "Property_Mass.New_Net_Usable_Extent,Property_Mass.New_Total_Land_Factor, Property_Mass.New_AdJ_Extent_1, Property_Mass.New_Points_1," _<br />
& "Property_Mass.New_ADJ_Extent_2, Property_Mass.New_Points_2, Property_Mass.LS_Prediction, Property_Mass.LS_Confidence, Property_Mass.LS_TYPE," _<br />
& "Property_Summary.Purchase_Date, Property_Summary.Purchase_Price" _<br />
& "from Property_Mass, Property_Summary" _<br />
& " where Property_Mass.Lis_key = Property_Summary.Lis_key"<br />
da = New SqlDataAdapter(strSql, cn)<br />
<br />
'load the Data set<br />
Try<br />
da.Fill(ds, "Property_Summary")<br />
'Close the Connection<br />
cn.Close()<br />
<br />
'Create relations <br />
ds.Relations.Add("Property_summary_Mass", _<br />
ds.Tables("Property_Mass").Columns("Lis_key"), _<br />
ds.Tables("Property_Summary").Columns("Lis_key"))<br />
<br />
'Bind the data set to the grid.<br />
'Assumes that Grid contains a reference to a <br />
'system.windows.datagrid<br />
DataGrid2.SetDataBinding(ds, "Property_Mass")<br />
Catch ExSQL As System.Data.SqlClient.SqlException<br />
'''All this will trap all data Problems and Network if available<br />
For Each strerror In ExSQL.Errors<br />
Next<br />
Select Case strerror.Number<br />
Case 17<br />
strErrorMsg = "Missing server"<br />
Case 4060<br />
strErrorMsg = "Missing database"<br />
Case 18456<br />
strErrorMsg = "Missing user name or password"<br />
Case Else<br />
strErrorMsg = strerror.Message<br />
End Select<br />
MessageBox.Show(strErrorMsg, "SQL Server Error: " & strerror.Number, MessageBoxButtons.OK, MessageBoxIcon.Error)<br />
<br />
Catch ExcpInvOp As System.InvalidOperationException<br />
<br />
MessageBox.Show("Close the connection first!", "Invalid Operation", MessageBoxButtons.OK, MessageBoxIcon.Error)<br />
<br />
Catch Excp As System.Exception ' generic exception handler<br />
<br />
MessageBox.Show(Excp.Message, "Unexpected Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)<br />
End Try<br />
End Sub<br />
but i still have one different Error, it says
Column Prefix 'Property_Summary' does not match with a table name or alias name used in this query.
Thanks
Vuyiswa Maseko
|
|
|
|
|
The Problem was so small, it was the Spaces provided in strSQl,
<br />
Dim strErrorMsg As String<br />
Dim strerror As System.Data.SqlClient.SqlError<br />
<br />
Dim strconnection As String = "workstation id=5875-049;packet size=4096;user id=sde;Password=topology;data source=SGIICORNETGS01;persist security info=False;initial catalog=Tshwane_Valuations"<br />
Dim cn As SqlConnection = New SqlConnection(strconnection)<br />
cn.Open()<br />
'set up the data soruce <br />
Dim strSql As String = _<br />
"select Actual_Extent,Attrib_code,Lis_key,Func_key,Density," _<br />
& "New_Net_Usable_Extent,New_Total_Land_Factor,New_AdJ_Extent_1,New_Points_1," _<br />
& "New_ADJ_Extent_2, New_Points_2, LS_Prediction, LS_Confidence from Property_Mass "<br />
Dim da As SqlDataAdapter = New SqlDataAdapter(strSql, cn)<br />
<br />
'load a Dataset <br />
Dim ds As DataSet = New DataSet<br />
da.Fill(ds, "Property_mass")<br />
<br />
'set up a new data adapter object <br />
strSql = _<br />
"select Property_Mass.Actual_Extent,Property_Mass.Attrib_code,Property_Mass.Lis_key,Property_Mass.Func_key,Property_Mass.Density," _<br />
& " Property_Mass.New_Net_Usable_Extent,Property_Mass.New_Total_Land_Factor,Property_Mass.New_AdJ_Extent_1, Property_Mass.New_Points_1," _<br />
& " Property_Mass.New_ADJ_Extent_2, Property_Mass.New_Points_2, Property_Mass.LS_Prediction, Property_Mass.LS_Confidence, Property_Mass.LS_TYPE," _<br />
& " Property_Summary.Purchase_Date, Property_Summary.Purchase_Price" _<br />
& " from Property_Mass, Property_Summary" _<br />
& " where Property_Mass.Lis_key = Property_Summary.Lis_key"<br />
da = New SqlDataAdapter(strSql, cn)<br />
<br />
'load the Data set<br />
Try<br />
da.Fill(ds, "Property_Summary")<br />
'Close the Connection<br />
cn.Close()<br />
<br />
'Create relations <br />
ds.Relations.Add("Property_summary_Mass", _<br />
ds.Tables("Property_Mass").Columns("Lis_key"), _<br />
ds.Tables("Property_Summary").Columns("Lis_key"))<br />
<br />
'Bind the data set to the grid.<br />
'Assumes that Grid contains a reference to a <br />
'system.windows.datagrid<br />
DataGrid2.SetDataBinding(ds, "Property_Mass")<br />
Catch ExSQL As System.Data.SqlClient.SqlException<br />
'''All this will trap all data Problems and Network if available<br />
For Each strerror In ExSQL.Errors<br />
Next<br />
Select Case strerror.Number<br />
Case 17<br />
strErrorMsg = "Missing server"<br />
Case 4060<br />
strErrorMsg = "Missing database"<br />
Case 18456<br />
strErrorMsg = "Missing user name or password"<br />
Case Else<br />
strErrorMsg = strerror.Message<br />
End Select<br />
MessageBox.Show(strErrorMsg, "SQL Server Error: " & strerror.Number, MessageBoxButtons.OK, MessageBoxIcon.Error)<br />
<br />
Catch ExcpInvOp As System.InvalidOperationException<br />
<br />
MessageBox.Show("Close the connection first!", "Invalid Operation", MessageBoxButtons.OK, MessageBoxIcon.Error)<br />
<br />
Catch Excp As System.Exception ' generic exception handler<br />
<br />
MessageBox.Show(Excp.Message, "Unexpected Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)<br />
End Try<br />
Thanks, i think i solved my Problem myself, if you have any suggestion about my code please comment, thanks
Vuyiswa Maseko
|
|
|
|
|