469,898 Members | 1,765 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

Using web service

Hi

I need to be able to call a web service method, receive the dataset that web
method returns and store it in an access table. My problem is that I don't
know how to "receive" a complex type like a dataset and how to link it to
the access table that it is supposed to go in. Could someone please give me
a code example?

Thanks

Regards
Nov 20 '05 #1
8 1383
Hi John,

A complete sample it gets an image from disk puts that in an dataset, gives
it to a webserver where it is saved as a dataset, readed again and it uses
as transport a dataset using webservice.
(With the buttons on the form)

It is not ready yet there are no comment lines for that you have to wait
something longer,

However I hope this helps?

Cor

\\\needs a picturebox and 4 buttons on a windowform
Dim ds As New DataSet
Private abyt() As Byte
Private fo As New OpenFileDialog
Private sf As New SaveFileDialog
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
'Reading a picture from disk and put it in a bytearray
If fo.ShowDialog = DialogResult.OK Then
Dim fs As New IO.FileStream(fo.FileName, _
IO.FileMode.Open)
Dim br As New IO.BinaryReader(fs)
abyt = br.ReadBytes(CInt(fs.Length))
br.Close()
'just to show the sample without a fileread error
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms)
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button2.Click
'writing a picture from a bytearray to disk
If sf.ShowDialog = DialogResult.OK Then
Dim fs As New IO.FileStream(sf.FileName, _
IO.FileMode.CreateNew)
Dim bw As New IO.BinaryWriter(fs)
bw.Write(abyt)
bw.Close()
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button3.Click
'writing a bytearray to a webservice dataset
Dim ws As New localhost.DataBaseUpdate
ws.SetDataset(abyt)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button4.Click
'reading a picture from a webservice dataset
Dim ws As New localhost.DataBaseUpdate
abyt = ws.GetByte
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms)
End Sub
End Class
////
\\\\Webservice
<WebMethod()> _
Public Function GetByte() As Byte()
Dim ds As New DataSet
ds.ReadXml("C:\wsblob.xml")
Return CType(ds.Tables(0).Rows(0)(0), Byte())
End Function
<WebMethod()> _
Public Sub SetDataset(ByVal abyte As Byte())
Dim ds As New DataSet
ds.Tables.Add(New DataTable("Photo"))
ds.Tables(0).Columns.Add(New DataColumn("Sample"))
ds.Tables(0).Columns(0).DataType = GetType(System.Byte())
ds.Tables(0).Rows.Add(ds.Tables(0).NewRow)
ds.Tables(0).Rows(0)(0) = abyte
ds.WriteXml("C:\wsblob.xml", XmlWriteMode.WriteSchema)
End Sub
////
Nov 20 '05 #2
Hi,

HYPERLINK
"http://www.onteorasoftware.com/downloads/DibertWebServiceExample.zip"http://www.onteorasoftware.com/downloads/DibertWebServiceExample.zip

Ken

------------------------------------

From: John [mailto:jo**@nospam.infovis.co.uk]
Sent: Tuesday, June 22, 2004 1:48 PM
To: microsoft.public.dotnet.languages.vb
Subject: Using web service

Hi

I need to be able to call a web service method, receive the dataset that
web
method returns and store it in an access table. My problem is that I
don't
know how to "receive" a complex type like a dataset and how to link it
to
the access table that it is supposed to go in. Could someone please give
me
a code example?

Thanks

Regards
--
Incoming mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.3 - Release Date: 6/18/2004

--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.3 - Release Date: 6/18/2004
Nov 20 '05 #3
Thanks for this. I start reading a remote dataset in bytes wouldn't it be
too slow? Isn't there a way to read at least a record at a time? Otherwise,
can I receive and save the whole dataset locally as xml file, on which I can
open a local dataset?

Thanks

Regards

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uQ**************@TK2MSFTNGP10.phx.gbl...
Hi,

HYPERLINK
"http://www.onteorasoftware.com/downloads/DibertWebServiceExample.zip"http:/
/www.onteorasoftware.com/downloads/DibertWebServiceExample.zip
Ken

------------------------------------

From: John [mailto:jo**@nospam.infovis.co.uk]
Sent: Tuesday, June 22, 2004 1:48 PM
To: microsoft.public.dotnet.languages.vb
Subject: Using web service

Hi

I need to be able to call a web service method, receive the dataset that
web
method returns and store it in an access table. My problem is that I
don't
know how to "receive" a complex type like a dataset and how to link it
to
the access table that it is supposed to go in. Could someone please give
me
a code example?

Thanks

Regards
--
Incoming mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.3 - Release Date: 6/18/2004

--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.3 - Release Date: 6/18/2004

Nov 20 '05 #4
Hi John,

I am curious why you ignore my complete working sample of an XML dataset
with a webservice which does almost exactly as you describe (except the
simple action to place it in an access database)?

Cor
Nov 20 '05 #5
Hi Cor

Thanks for that.

Where does ds.WriteXml("C:\wsblob.xml", XmlWriteMode.WriteSchema) store the
xml file? On the pc calling the web service or the server where web service
residues?

My application is slightly different in that I want the remote dataset to
end up in a local access table. For an image image.fromstream makes it easy
but is there an easy way to get the remote dataset into an access table too?

Thanks

Regards

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OE**************@TK2MSFTNGP12.phx.gbl...
Hi John,

A complete sample it gets an image from disk puts that in an dataset, gives it to a webserver where it is saved as a dataset, readed again and it uses
as transport a dataset using webservice.
(With the buttons on the form)

It is not ready yet there are no comment lines for that you have to wait
something longer,

However I hope this helps?

Cor

\\\needs a picturebox and 4 buttons on a windowform
Dim ds As New DataSet
Private abyt() As Byte
Private fo As New OpenFileDialog
Private sf As New SaveFileDialog
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
'Reading a picture from disk and put it in a bytearray
If fo.ShowDialog = DialogResult.OK Then
Dim fs As New IO.FileStream(fo.FileName, _
IO.FileMode.Open)
Dim br As New IO.BinaryReader(fs)
abyt = br.ReadBytes(CInt(fs.Length))
br.Close()
'just to show the sample without a fileread error
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms)
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button2.Click
'writing a picture from a bytearray to disk
If sf.ShowDialog = DialogResult.OK Then
Dim fs As New IO.FileStream(sf.FileName, _
IO.FileMode.CreateNew)
Dim bw As New IO.BinaryWriter(fs)
bw.Write(abyt)
bw.Close()
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button3.Click
'writing a bytearray to a webservice dataset
Dim ws As New localhost.DataBaseUpdate
ws.SetDataset(abyt)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button4.Click
'reading a picture from a webservice dataset
Dim ws As New localhost.DataBaseUpdate
abyt = ws.GetByte
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms)
End Sub
End Class
////
\\\\Webservice
<WebMethod()> _
Public Function GetByte() As Byte()
Dim ds As New DataSet
ds.ReadXml("C:\wsblob.xml")
Return CType(ds.Tables(0).Rows(0)(0), Byte())
End Function
<WebMethod()> _
Public Sub SetDataset(ByVal abyte As Byte())
Dim ds As New DataSet
ds.Tables.Add(New DataTable("Photo"))
ds.Tables(0).Columns.Add(New DataColumn("Sample"))
ds.Tables(0).Columns(0).DataType = GetType(System.Byte())
ds.Tables(0).Rows.Add(ds.Tables(0).NewRow)
ds.Tables(0).Rows(0)(0) = abyte
ds.WriteXml("C:\wsblob.xml", XmlWriteMode.WriteSchema)
End Sub
////

Nov 20 '05 #6
Hi John,

You can just move it into the dataset of the acces file, or when the dataset
is equal to the access table you can even insert it. I do not believe in
that because when you than does that twice you have a constraint error. I
think it is better just to get the item from the dataset and set that in the
with the key readed access datatable and than update that.

Than you can update when it exist and insert it when it is new using the
normal dataadapter technique.

However where comes your data from, than I can maybe make a sample what
looks something more like that.

However I am writing this while you no that there is EK, so I review this
tomorrow when this is a problem. Message that than.

In my opinion it is even easier to put it in an Access file than writting it
to disk.

A pity you did not answer earlier, I am busy tomorrow when I have time I
will try to give you an example of that tomorrow but that will than not
early

(When you do not need that message that than)

Cor

Thanks for that.

Where does ds.WriteXml("C:\wsblob.xml", XmlWriteMode.WriteSchema) store the xml file? On the pc calling the web service or the server where web service residues?

My application is slightly different in that I want the remote dataset to
end up in a local access table. For an image image.fromstream makes it easy but is there an easy way to get the remote dataset into an access table too?
Thanks

Regards

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OE**************@TK2MSFTNGP12.phx.gbl...
Hi John,

A complete sample it gets an image from disk puts that in an dataset,

gives
it to a webserver where it is saved as a dataset, readed again and it uses as transport a dataset using webservice.
(With the buttons on the form)

It is not ready yet there are no comment lines for that you have to wait
something longer,

However I hope this helps?

Cor

\\\needs a picturebox and 4 buttons on a windowform
Dim ds As New DataSet
Private abyt() As Byte
Private fo As New OpenFileDialog
Private sf As New SaveFileDialog
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
'Reading a picture from disk and put it in a bytearray
If fo.ShowDialog = DialogResult.OK Then
Dim fs As New IO.FileStream(fo.FileName, _
IO.FileMode.Open)
Dim br As New IO.BinaryReader(fs)
abyt = br.ReadBytes(CInt(fs.Length))
br.Close()
'just to show the sample without a fileread error
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms)
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button2.Click
'writing a picture from a bytearray to disk
If sf.ShowDialog = DialogResult.OK Then
Dim fs As New IO.FileStream(sf.FileName, _
IO.FileMode.CreateNew)
Dim bw As New IO.BinaryWriter(fs)
bw.Write(abyt)
bw.Close()
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button3.Click
'writing a bytearray to a webservice dataset
Dim ws As New localhost.DataBaseUpdate
ws.SetDataset(abyt)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button4.Click
'reading a picture from a webservice dataset
Dim ws As New localhost.DataBaseUpdate
abyt = ws.GetByte
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms)
End Sub
End Class
////
\\\\Webservice
<WebMethod()> _
Public Function GetByte() As Byte()
Dim ds As New DataSet
ds.ReadXml("C:\wsblob.xml")
Return CType(ds.Tables(0).Rows(0)(0), Byte())
End Function
<WebMethod()> _
Public Sub SetDataset(ByVal abyte As Byte())
Dim ds As New DataSet
ds.Tables.Add(New DataTable("Photo"))
ds.Tables(0).Columns.Add(New DataColumn("Sample"))
ds.Tables(0).Columns(0).DataType = GetType(System.Byte())
ds.Tables(0).Rows.Add(ds.Tables(0).NewRow)
ds.Tables(0).Rows(0)(0) = abyte
ds.WriteXml("C:\wsblob.xml", XmlWriteMode.WriteSchema)
End Sub
////


Nov 20 '05 #7
Hi John,

As told above simple (I have made the access database in this sample, that
is the major part, while I as well have used the dataset which comes direct
from the Access database to keep the sample simple)

I hope this helps?

Cor

\\\
'Needs a form with 2 buttons
'set a reference to ado ext 2.7 for blabla
Private conn As New
OleDb.OleDbConnection("Provider=Microsoft.Jet.OLED B.4.0;" & _
"Data Source=C:\db1.mdb;User Id=admin;Password=;")
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim da As New OleDb.OleDbDataAdapter("Select * from countries",
conn)
Dim ds As New DataSet
da.Fill(ds)
ds.Tables(0).Rows.Add(ds.Tables(0).NewRow())
ds.Tables(0).Rows(0)(1) = 1
ds.Tables(0).Rows(0)(2) = "Holland"
Dim ws As New localhost.DataBaseUpdate
ws.SetDataset(ds)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button2.Click
Dim da As New OleDb.OleDbDataAdapter("Select * from countries",
conn)
Dim ds As New DataSet
Dim cmd As New OleDb.OleDbCommandBuilder(da)
Dim ws As New localhost.DataBaseUpdate
ds = ws.GetDataset()
da.Update(ds)
End Sub
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim catNewDB As New ADOX.Catalog
Dim fi As New IO.FileInfo("c:\db1.mdb")
If fi.Exists Then
If MessageBox.Show("Delete?", "Existing File db1.mdb", _
MessageBoxButtons.YesNo) = DialogResult.Yes Then
fi.Delete()
Else
Exit Sub
End If
End If
catNewDB.Create("Provider=Microsoft.Jet.OLEDB.4.0; " & "Data
Source=C:\db1.mdb")
Dim cmd As New OleDb.OleDbCommand("CREATE TABLE countries ( " & _
"AutoId int identity ," & _
"Id int NOT NULL," & _
"Name NVarchar(50)," & _
"CONSTRAINT [pk_AutoId] PRIMARY KEY (AutoId)) ", conn)
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
End Sub
///
\\\
<WebMethod()> _
Public Function GetDataset() As DataSet
Dim ds As New DataSet
ds.ReadXml("C:\wsTest.xml")
Return ds
End Function
<WebMethod()> _
Public Sub SetDataset(ByVal ds As DataSet)
ds.WriteXml("C:\wsTest.xml", XmlWriteMode.WriteSchema)
End Sub
///

,

You can just move it into the dataset of the acces file, or when the dataset is equal to the access table you can even insert it. I do not believe in
that because when you than does that twice you have a constraint error. I
think it is better just to get the item from the dataset and set that in the with the key readed access datatable and than update that.

Than you can update when it exist and insert it when it is new using the
normal dataadapter technique.

However where comes your data from, than I can maybe make a sample what
looks something more like that.

However I am writing this while you no that there is EK, so I review this
tomorrow when this is a problem. Message that than.

In my opinion it is even easier to put it in an Access file than writting it to disk.

A pity you did not answer earlier, I am busy tomorrow when I have time I
will try to give you an example of that tomorrow but that will than not
early

(When you do not need that message that than)

Cor

Thanks for that.

Where does ds.WriteXml("C:\wsblob.xml", XmlWriteMode.WriteSchema) store

the
xml file? On the pc calling the web service or the server where web

service
residues?

My application is slightly different in that I want the remote dataset to
end up in a local access table. For an image image.fromstream makes it

easy
but is there an easy way to get the remote dataset into an access table

too?

Thanks

Regards

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OE**************@TK2MSFTNGP12.phx.gbl...
Hi John,

A complete sample it gets an image from disk puts that in an dataset,

gives
it to a webserver where it is saved as a dataset, readed again and it

uses as transport a dataset using webservice.
(With the buttons on the form)

It is not ready yet there are no comment lines for that you have to wait something longer,

However I hope this helps?

Cor

\\\needs a picturebox and 4 buttons on a windowform
Dim ds As New DataSet
Private abyt() As Byte
Private fo As New OpenFileDialog
Private sf As New SaveFileDialog
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
'Reading a picture from disk and put it in a bytearray
If fo.ShowDialog = DialogResult.OK Then
Dim fs As New IO.FileStream(fo.FileName, _
IO.FileMode.Open)
Dim br As New IO.BinaryReader(fs)
abyt = br.ReadBytes(CInt(fs.Length))
br.Close()
'just to show the sample without a fileread error
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms)
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button2.Click
'writing a picture from a bytearray to disk
If sf.ShowDialog = DialogResult.OK Then
Dim fs As New IO.FileStream(sf.FileName, _
IO.FileMode.CreateNew)
Dim bw As New IO.BinaryWriter(fs)
bw.Write(abyt)
bw.Close()
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button3.Click
'writing a bytearray to a webservice dataset
Dim ws As New localhost.DataBaseUpdate
ws.SetDataset(abyt)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button4.Click
'reading a picture from a webservice dataset
Dim ws As New localhost.DataBaseUpdate
abyt = ws.GetByte
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms)
End Sub
End Class
////
\\\\Webservice
<WebMethod()> _
Public Function GetByte() As Byte()
Dim ds As New DataSet
ds.ReadXml("C:\wsblob.xml")
Return CType(ds.Tables(0).Rows(0)(0), Byte())
End Function
<WebMethod()> _
Public Sub SetDataset(ByVal abyte As Byte())
Dim ds As New DataSet
ds.Tables.Add(New DataTable("Photo"))
ds.Tables(0).Columns.Add(New DataColumn("Sample"))
ds.Tables(0).Columns(0).DataType = GetType(System.Byte())
ds.Tables(0).Rows.Add(ds.Tables(0).NewRow)
ds.Tables(0).Rows(0)(0) = abyte
ds.WriteXml("C:\wsblob.xml", XmlWriteMode.WriteSchema)
End Sub
////



Nov 20 '05 #8
Hi Cor

That's excellent! Thanks for this. Works fine for me.

Regards

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi John,

As told above simple (I have made the access database in this sample, that
is the major part, while I as well have used the dataset which comes direct from the Access database to keep the sample simple)

I hope this helps?

Cor

\\\
'Needs a form with 2 buttons
'set a reference to ado ext 2.7 for blabla
Private conn As New
OleDb.OleDbConnection("Provider=Microsoft.Jet.OLED B.4.0;" & _
"Data Source=C:\db1.mdb;User Id=admin;Password=;")
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim da As New OleDb.OleDbDataAdapter("Select * from countries",
conn)
Dim ds As New DataSet
da.Fill(ds)
ds.Tables(0).Rows.Add(ds.Tables(0).NewRow())
ds.Tables(0).Rows(0)(1) = 1
ds.Tables(0).Rows(0)(2) = "Holland"
Dim ws As New localhost.DataBaseUpdate
ws.SetDataset(ds)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button2.Click
Dim da As New OleDb.OleDbDataAdapter("Select * from countries",
conn)
Dim ds As New DataSet
Dim cmd As New OleDb.OleDbCommandBuilder(da)
Dim ws As New localhost.DataBaseUpdate
ds = ws.GetDataset()
da.Update(ds)
End Sub
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim catNewDB As New ADOX.Catalog
Dim fi As New IO.FileInfo("c:\db1.mdb")
If fi.Exists Then
If MessageBox.Show("Delete?", "Existing File db1.mdb", _
MessageBoxButtons.YesNo) = DialogResult.Yes Then
fi.Delete()
Else
Exit Sub
End If
End If
catNewDB.Create("Provider=Microsoft.Jet.OLEDB.4.0; " & "Data
Source=C:\db1.mdb")
Dim cmd As New OleDb.OleDbCommand("CREATE TABLE countries ( " & _
"AutoId int identity ," & _
"Id int NOT NULL," & _
"Name NVarchar(50)," & _
"CONSTRAINT [pk_AutoId] PRIMARY KEY (AutoId)) ", conn) conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
End Sub
///
\\\
<WebMethod()> _
Public Function GetDataset() As DataSet
Dim ds As New DataSet
ds.ReadXml("C:\wsTest.xml")
Return ds
End Function
<WebMethod()> _
Public Sub SetDataset(ByVal ds As DataSet)
ds.WriteXml("C:\wsTest.xml", XmlWriteMode.WriteSchema)
End Sub
///

,

You can just move it into the dataset of the acces file, or when the dataset
is equal to the access table you can even insert it. I do not believe in
that because when you than does that twice you have a constraint error. I
think it is better just to get the item from the dataset and set that in

the
with the key readed access datatable and than update that.

Than you can update when it exist and insert it when it is new using the
normal dataadapter technique.

However where comes your data from, than I can maybe make a sample what
looks something more like that.

However I am writing this while you no that there is EK, so I review this tomorrow when this is a problem. Message that than.

In my opinion it is even easier to put it in an Access file than writting it
to disk.

A pity you did not answer earlier, I am busy tomorrow when I have time I
will try to give you an example of that tomorrow but that will than not
early

(When you do not need that message that than)

Cor

Thanks for that.

Where does ds.WriteXml("C:\wsblob.xml", XmlWriteMode.WriteSchema) store the
xml file? On the pc calling the web service or the server where web

service
residues?

My application is slightly different in that I want the remote dataset to end up in a local access table. For an image image.fromstream makes it

easy
but is there an easy way to get the remote dataset into an access
table too?

Thanks

Regards

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OE**************@TK2MSFTNGP12.phx.gbl...
> Hi John,
>
> A complete sample it gets an image from disk puts that in an
dataset, gives
> it to a webserver where it is saved as a dataset, readed again and

it uses
> as transport a dataset using webservice.
> (With the buttons on the form)
>
> It is not ready yet there are no comment lines for that you have to

wait > something longer,
>
> However I hope this helps?
>
> Cor
>
> \\\needs a picturebox and 4 buttons on a windowform
> Dim ds As New DataSet
> Private abyt() As Byte
> Private fo As New OpenFileDialog
> Private sf As New SaveFileDialog
> Private Sub Button1_Click(ByVal sender As System.Object, _
> ByVal e As System.EventArgs) Handles Button1.Click
> 'Reading a picture from disk and put it in a bytearray
> If fo.ShowDialog = DialogResult.OK Then
> Dim fs As New IO.FileStream(fo.FileName, _
> IO.FileMode.Open)
> Dim br As New IO.BinaryReader(fs)
> abyt = br.ReadBytes(CInt(fs.Length))
> br.Close()
> 'just to show the sample without a fileread error
> Dim ms As New IO.MemoryStream(abyt)
> Me.PictureBox1.Image = Image.FromStream(ms)
> End If
> End Sub
> Private Sub Button2_Click(ByVal sender As System.Object, ByVal _
> e As System.EventArgs) Handles Button2.Click
> 'writing a picture from a bytearray to disk
> If sf.ShowDialog = DialogResult.OK Then
> Dim fs As New IO.FileStream(sf.FileName, _
> IO.FileMode.CreateNew)
> Dim bw As New IO.BinaryWriter(fs)
> bw.Write(abyt)
> bw.Close()
> End If
> End Sub
> Private Sub Button3_Click(ByVal sender As System.Object, ByVal _
> e As System.EventArgs) Handles Button3.Click
> 'writing a bytearray to a webservice dataset
> Dim ws As New localhost.DataBaseUpdate
> ws.SetDataset(abyt)
> End Sub
> Private Sub Button4_Click(ByVal sender As System.Object, _
> ByVal e As System.EventArgs) Handles Button4.Click
> 'reading a picture from a webservice dataset
> Dim ws As New localhost.DataBaseUpdate
> abyt = ws.GetByte
> Dim ms As New IO.MemoryStream(abyt)
> Me.PictureBox1.Image = Image.FromStream(ms)
> End Sub
> End Class
> ////
> \\\\Webservice
> <WebMethod()> _
> Public Function GetByte() As Byte()
> Dim ds As New DataSet
> ds.ReadXml("C:\wsblob.xml")
> Return CType(ds.Tables(0).Rows(0)(0), Byte())
> End Function
> <WebMethod()> _
> Public Sub SetDataset(ByVal abyte As Byte())
> Dim ds As New DataSet
> ds.Tables.Add(New DataTable("Photo"))
> ds.Tables(0).Columns.Add(New DataColumn("Sample"))
> ds.Tables(0).Columns(0).DataType = GetType(System.Byte())
> ds.Tables(0).Rows.Add(ds.Tables(0).NewRow)
> ds.Tables(0).Rows(0)(0) = abyte
> ds.WriteXml("C:\wsblob.xml", XmlWriteMode.WriteSchema)
> End Sub
> ////
>
>



Nov 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by raghavendra | last post: by
6 posts views Thread by Nathan Kovac | last post: by
14 posts views Thread by pmud | last post: by
5 posts views Thread by Derek Martin | last post: by
3 posts views Thread by Michael Hoehne | last post: by
3 posts views Thread by =?Utf-8?B?RGFuZGFuIFpoYW5n?= | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.