Click here to Skip to main content
15,911,485 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
Hi,
I wanted to ask on how to get webservice result ( i made it return value as Dataset, but it's NOT must. I might be return it as String or Datatable too if it necessary) as value in textbox (textbox.text) or label?

I have this as my webservice ( for example )
<WebMethod()> _
   Public Function AmbilBuku() As Dataset
       Dim conn As String
       conn = "server=localhost;uid=root;pwd=;database=uptbahasa"

       Dim sql As String = "Select * from buku

       Dim konek As New MySqlConnection(conn)
       Dim OdbcDa As New MySqlDataAdapter(sql, conn)
       konek.Open()
       Dim ds As New DataSet
       OdbcDa.Fill(ds)
       Return ds
   End Function


From that I return the query result as dataset, and will throw me some result like this (if I browse it through browser).

<dataset>>
	<xs:schema id="NewDataSet">
	<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
		<xs:complexType><xs:choice minOccurs="0" maxOccurs="unbounded">
			<xs:element name="Table">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="id" type="xs:int" minOccurs="0"/>
						<xs:element name="username" type="xs:string" minOccurs="0"/>
						<xs:element name="password" type="xs:string" minOccurs="0"/>
						<xs:element name="grup" type="xs:string" minOccurs="0"/>
					</xs:sequence>
				</xs:complexType>
			</xs:element></xs:choice></xs:complexType></xs:element>
	</xs:schema>
<diffgr:diffgram>
	<NewDataSet>
		<Table diffgr:id="Table1" msdata:rowOrder="0">
			<id>1</id>
			<username>admin</username>
			<password>21232f297a57a5a743894a0e4a801fc3</password>
			<grup>administrator</grup></Table>
		<Table diffgr:id="Table2" msdata:rowOrder="1">
		<id>11</id>
		<username>Yoyo</username>
		<password>48dc8d29308eb256edc76f25def07251</password>
		<grup>operator</grup>
		</Table>
</NewDataSet>
</diffgr:diffgram>
</DataSet>


My question is how to get for example ID and Username as textbox.text in my windows form?

Thanks a lot in advance.
Posted
Updated 5-Jun-11 19:38pm
v5
Comments
cuteband 6-Jun-11 1:58am    
Here is the trick on this In your Strored Procedure or In your class Create an array before you return it in a string. And that will works
satrio_budidharmawan 6-Jun-11 3:55am    
How could I do that?
can u give me an example?Where should I put it?on my Webservice or Windows form?

Thanks everyone, I had it finished.

This how I do it

on the FOR LOOP I use this :
ds.tables(0).rows(0).item(i).tostring

Now I facing new problem, on how to create Report in Smartdevice. The report I need is just like the result of transactions (just like in PoS software).

Anyone know?
 
Share this answer
 
v2
VB
return ctype(ds, dataset)


This forces it to be a dataset rather than being a diffgram dataset
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900