Hi all...
I'm trying to retrieve a SQLXML query using VB.NET. When I programmed in VB
6.0, I used Stream object to accomplish this which was trivial.
I cannot do the same thing in VB.NET. Here the most similar object is the
OleDbDataReader. I have the following method, ¿is it correct what I am
doing? By doing oRdr.GetBytes(0, 0, bBytes, 0, 1000) I'm limiting only to
1000 bytes. How can I know the length of the stream?
Public Function get_Tree(Optional ByVal sEstado As String = "") As String
Dim oConn As New OleDbConnection(m_sConn)
oConn.Open()
Dim oCmd As New OleDbCommand("SP_GET_CATEGORY_TREE", oConn)
Dim oParamEst As OleDbParameter = New OleDbParameter("@CAT_EST",
OleDbType.VarChar, Len(sEstado))
oParamEst.Value = sEstado
oCmd.Parameters.Add(oParamEst)
oCmd.CommandType = CommandType.StoredProcedure
Dim oRdr As OleDbDataReader = oCmd.ExecuteReader
If oRdr.Read Then
Dim bBytes(1000) As Byte
oRdr.GetBytes(0, 0, bBytes, 0, 1000)
Return "" ' I NEED TO RETURN THE XML THAT IS RETURNED FROM
THE SQL SP (AS FOR XML AUTO)
End If
End Function
Any help will be greately appreciated,
Jaime 2 2498
Jaime,
See this snippet.
\\\
"DataBase=Northwind; Integrated Security=SSPI")
Dim sqlstr As String = _
String.Format("SELECT Photo FROM Employees WHERE (EmployeeID =
{0})", _
CInt(Session.Item("img")))
Dim cmd As New SqlClient.SqlCommand(sqlstr, conn)
conn.Open()
Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader()
rdr.Read()
Dim arrImage() As Byte = DirectCast(rdr.Item("Photo"), Byte())
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''
'Dim ms1 As New System.IO.MemoryStream(arrImage)
'The one above is for normal purpose, however Northwind has a
strange format
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''
Dim ms1 As New System.IO.MemoryStream(arrImage, 78,
arrImage.Length - 78)
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''
Dim origimage As System.drawing.Image =
System.Drawing.Image.FromStream(ms1)
///
I hope this helps,
Cor
"Jaime Stuardo" <js******@manquehue.net> schrieb: I'm trying to retrieve a SQLXML query using VB.NET. When I programmed in VB 6.0, I used Stream object to accomplish this which was trivial.
I cannot do the same thing in VB.NET. Here the most similar object is the OleDbDataReader. I have the following method, ¿is it correct what I am doing? By doing oRdr.GetBytes(0, 0, bBytes, 0, 1000) I'm limiting only to 1000 bytes. How can I know the length of the stream?
I cannot give you an answer on the database stuff. However, you can use
'System.Text.Encoding.<encoding name>.GetString' to convert a byte array to
a string.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Swarup |
last post by:
I am reading a file (txt, xml, gif, ico, bmp etc) byte by byte and filling
it into a byte arry. Now i have to convert it into a string to store it in
the database.
I use...
|
by: Ricardo Quintanilla |
last post by:
i have a code that sends data to a socket listening over as400 platform,
the socket responds to me as a "byte array".
then i need to convert the "byte array" into a string.
the problem is that...
|
by: Kueishiong Tu |
last post by:
How do I convert a Byte array (unsigned char managed) to a
char array(unmanaged) with wide character taken into
account?
|
by: Allan Ebdrup |
last post by:
How do I easily convert a int to a string?
Kind Regards,
Allan Ebdrup
|
by: moondaddy |
last post by:
I'm writing an app in vb.net 1.1 and need to convert a byte array into a
string, and then from a string back to a byte array.
for example
Private mByte() as New Byte(4){11,22,33,44}
Now how...
|
by: Bob Altman |
last post by:
Hi all,
I'm looking for the fastest way to convert an array of bytes to String. I
also need to convert a String back to its original Byte() representation.
Convert.ToBase64String and...
|
by: Peter |
last post by:
Trying to convert string to byte array.
the following code returns byte array of {107, 62, 194, 139, 64}
how can I convert this string to a byte array of {107, 62, 139, 65}
...
|
by: est |
last post by:
From python manual
str( )
Return a string containing a nicely printable representation of an
object. For strings, this returns the string itself. The difference
with repr(object) is that...
|
by: da1978 |
last post by:
Hi experts,
I need to convert a string or a Byte array to a string byte array.
Its relatively easy to convert a string to an char array or a byte array but not a
STRING byte array. i.e.
...
|
by: Debadatta Mishra |
last post by:
Introduction
In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |