|
Dear All,
I used OLe Container in VB6.0 to upload image to database.
The image is saved in database as compounded file binary.
Now I am using VB.NET to retrieve the file.. but somehow I could not extract the
embedded file from that OLE Binary.
Does someone have a workaround for this?
Much Appreciated.
Sandy
|
|
|
|
|
This should work for you. I know that it works with MS-Access. Assuming you table contains the following fields
IMAGE_ITEM_ID : Long
NAME : Text
IMAGE : OLE Object
Public Sub GetItem(ByVal itemId As Long)
Dim sqlQuery As String ' the query to execute
Dim image() As Byte ' the image to get
Dim name as String ' the name of the image
sqlQuery = "SELECT IMAGE_ITEM_ID, NAME, IMAGE " & _
"FROM IMAGE_ITEM " &_
"WHERE IMAGE_ITEM_ID = " & itemId
Try
' instanciate a connection object
Dim conn As OleDb.OleDbConnection = GetConnection()
' instanciate a command object
Dim com As New OleDbCommand(sqlQuery, conn)
' open the connection
com.Connection.Open()
' create a read to read the database
Dim reader As OleDbDataReader
' open the reader
reader = com.ExecuteReader(CommandBehavior.CloseConnection)
' read the first record
If (reader.Read()) Then
' get the name of the image
name = reader.GetString(1)
' get the image
itemData.Image = CType(reader.Item(2), Byte())
End If
' clean up after yourself
reader.Close()
com.Connection.Close()
conn.Dispose() 'release memory to garbage collection
com.Dispose() 'release memory to garbage collection
Catch eOleDb As OleDb.OleDbException
MsgBox("OleDb Error - GetItem - [" & eOleDb.Message & "]")
End Try
End Sub
I hope it works for you.
|
|
|
|
|
What is the best practice for generating a standard report in a VB.NET app?
I have tabbed form a user fills out then clicks file, print to print the record just created. Printing the data entry screen is not an option. For instance you fill out a customer order then you want to print the order. Do you create another windows form or is there a special type of form for printing?
I know this is a newbie question but I am just looking for some general guidance not a step by step walk through.
Thanks,
Sean
|
|
|
|
|
Hi Sean. You could use a dedicated report control, like Crystal Reports for this. You could also investigate the PrintDocument class - to print a customer order, you could either sub-class PrintDocument or add your own event handler to respond to the PrintDocument's PrintPage event. The .NET SDK documentation has some examples.
|
|
|
|
|
hello to all
i am using this code to send a message from my system (sys 1) to the other system (sys 2).
its working fine..... for this i need to use APIs. but i want to send a message using the shell command. can any body give the exact syntax for it ?.
next one ... is there any way to know in/from the sencond system (sys 2) ( ... to which i am sending the message ) that it has got the message when ever i send a message to sys 2 ?.
so that i can show a popup (just like msn messenger do) or play some sound when ever sys 2 gets a message from sys 1.
here is the code ...
Private Declare Function NetMessageBufferSend Lib "NETAPI32.DLL" (yServer As Any, yToName As Byte, yFromName As Any, yMsg As Byte, ByVal lSize As Long) As Long
Private Const NERR_Success As Long = 0&
Public Function BroadcastMessage(sToUser As String, sFromUser As String, sMessage As String) As Boolean
Dim yToName() As Byte
Dim yFromName() As Byte
Dim yMsg() As Byte
Dim l As Long
yToName = sToUser & vbNullChar
yFromName = sFromUser & vbNullChar
yMsg = sMessage & vbNullChar
If NetMessageBufferSend(ByVal 0&, yToName(0), ByVal 0&, _
yMsg(0), UBound(yMsg)) = NERR_Success Then
BroadcastMessage = True
End If
End Function
Private Sub Command1_Click()
Dim x As Boolean
x = BroadcastMessage(TxtTo.Text, TxtFrom.Text, TxtMsg.Text)
If x Then
MsgBox "Message Sent"
Else
MsgBox "Message Not Sent"
End If
End Sub
any body please help me
Mohan G
|
|
|
|
|
hi there, basically i am new to VB.net and need a bit of help
i have a string like "Track 01 (2.33)". this string is an item of of a combo box
what i need to do is by clicking a button separating "Track 01" and put it in a list box and "2.33" in another list box...
can you help me plaese?
|
|
|
|
|
I assume you know how to put the item into the list box.
to split the string you can you
String.Split or you can use Instr(), Left(),Mid(), and Right().
Dim pos As Integer
Dim lstr As String
Dim rstr As String
Dim str As String
str = "track 01 (2.33)"
pos = InStr(str,"(")
If pos <> 0 Then
lstr = Left(str,pos)
rstr = Right(str,Len(str)-pos)
good luck
|
|
|
|
|
I am a newbie programing with VB.NET. I need to write an app separating Data Access Layer and form. In my DAL I have the following method:
Public Function GetcboRelationsDataSet() As cboRelationsDataSet
Dim ds As New cboRelationsDataSet
Try
cboRelationsDataAdapter.Fill(ds)
return ds
Catch exc As Exception
Dim msg As String
msg = "Error reading Widget List from database"
Throw New DALException(msg, exc, Nothing)
End Try
End Function
And in my form this code to bind the dataset:
Private Sub frmListeRelations_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim rh As New RelationsHandler
Try
lstRelations.DataSource = rh.GetcboRelationsDataSet
lstRelations.DisplayMember = "sNom"
lstRelations.Refresh()
Catch ex As Exception
End Try
End Sub
Is this correct ? The code runs fine but no data comes up.
jean-luc
|
|
|
|
|
I’m working on a project which is designed to collect data (a LOT of data) from the user and store it in a database. In VB6 I probably would have used multiple forms (I’m still just learning though) but with VB.NET it seems more practical to use one form with multiple userControls and each userControl containing panels and each panel containing the necessary controls to collect the data.
My question is: Using a function under a btnNext, for example, how can I cycle through each of my panels?
Does anybody know of any good resources or examples that would illustrate this type of thing?
Thanks
Brad
|
|
|
|
|
Hi all,
I am facing a problem in a program of mine , i am designing a software that is tracking the users activities in IE , it matches the users url requests with an internal db of restricted urls and if found can close the IE , but the problem is reading the content in the address bar makes the IE close even from the IE cache ,, i want to allow the url to remain i the cache and the user can type it in the address bar as well (previously i was blocking as soon as the user was typing it.) but when the user hits the enter key or url i want to block it. Problem is how i know or trap whether the page has started to load or the IE has load it.I want to block it on request. How i do that .. Please advice ...
Thanks in advance ...
Sohel
Sohel Shaheen Mallik
Tathya Dot Com Pvt. Ltd.
Junior Programmer
Kolkata , 700059
+9103325734224(O)
+9103325738041(O)
+9103422530913(R)
---------------------
It Goes On !!
|
|
|
|
|
I have a VB project that contains a number of controls. The project is called Controls and one of the controls for example is called Label. So when used in another project the control type name is Controls.Label. Fair enough.
I have reimplemented the Controls library containing the controls in ATL keeping all the original GUIDS, IIDs and names to maintain compatibility. But VB insists on appending Ctl to my name, making it 'ControlsCtl.Label'. This makes the orginal VB form fail to load.
Any ideas?
|
|
|
|
|
Hi folks, I got a simple question! How do I make .NET menu look flat like VS. I succeeded in reproducing all but the flatness, it seems that the menu control always follows up my OS (Win200). Here is the function I use to draw my menu items, what am I missing. Please help me out I need it to complete a release (on a no royalty product). Thanks
No mather wahat I do my menu still look like 2000 with the .NET feel.
------------------------------------------------------------------------
Sub DrawItems(ByVal EvDrawItems As System.Windows.Forms.DrawItemEventArgs, _
ByVal Mi As MenuItem, _
ByVal m_Icon As Icon)
Dim br As Brush
Dim fDisposeBrush As Boolean
Dim img As Image
Dim br2 As New SolidBrush(Color.Silver)
Dim iSelFac As Integer = 0
Dim imgblk As Image
img = GetIconFromMapping(Mi)
EvDrawItems.DrawBackground()
EvDrawItems.Graphics.FillRectangle(br2, EvDrawItems.Bounds)
EvDrawItems.Graphics.FillRectangle(m_SideBarBrush,
EvDrawItems.Bounds.Left,
EvDrawItems.Bounds.Top, 24, 26)
If CBool(EvDrawItems.State And DrawItemState.Selected) Then
iSelFac = 1
End If
If Not img Is Nothing Then
imgblk = img
If CBool(EvDrawItems.State And DrawItemState.Selected) Then
Dim GDI As New GDI_Filters.Filters
GDI.GrayScale(imgblk)
EvDrawItems.Graphics.DrawImage(img, (EvDrawItems.Bounds.Left _
+ 6), _
(EvDrawItems.Bounds.Top + 6))
End If
EvDrawItems.Graphics.DrawImage(img, (EvDrawItems.Bounds.Left + 6) - iSelFac, _
(EvDrawItems.Bounds.Top + 6) - iSelFac)
If Mi.Checked Then
If (m_CheckImage <> -1) Then
EvDrawItems.Graphics.DrawImage(m_Icons.Images(m_CheckImage), (EvDrawItems.Bounds.Left + 6) - iSelFac, _
(EvDrawItems.Bounds.Top + 6) - iSelFac)
Else
EvDrawItems.Graphics.DrawImage(m_frmDummy.ImageList1.Images(0), (EvDrawItems.Bounds.Left + 6) - iSelFac, _
(EvDrawItems.Bounds.Top + 6) - iSelFac)
End If
End If
Else
If Mi.Checked Then
If (m_CheckImage <> -1) Then
EvDrawItems.Graphics.DrawImage(m_Icons.Images(m_CheckImage), (EvDrawItems.Bounds.Left + 6) - iSelFac, _
(EvDrawItems.Bounds.Top + 6) - iSelFac)
Else
EvDrawItems.Graphics.DrawImage(m_frmDummy.ImageList1.Images(0), (EvDrawItems.Bounds.Left + 6) - iSelFac, _
(EvDrawItems.Bounds.Top + 6) - iSelFac)
End If
End If
End If
Dim rcBk As Rectangle = EvDrawItems.Bounds
rcBk.X += 24
If CBool(EvDrawItems.State And DrawItemState.Selected) Then
br = New LinearGradientBrush(EvDrawItems.Bounds, Color.FromArgb(40, Color.Blue), Color.FromArgb(40, Color.Blue), 0)
fDisposeBrush = True
EvDrawItems.Graphics.FillRectangle(br, EvDrawItems.Bounds.Left + 2, rcBk.Top + 2, EvDrawItems.Bounds.Width - 4, rcBk.Height - 2)
ControlPaint.DrawBorder3D(EvDrawItems.Graphics, EvDrawItems.Bounds.Left + 2, rcBk.Top + 2, EvDrawItems.Bounds.Width - 4, rcBk.Height - 2, Border3DStyle.Flat)
End If
If fDisposeBrush Then br.Dispose()
br = Nothing
Dim sf As StringFormat = New StringFormat
sf.HotkeyPrefix = HotkeyPrefix.Show
sf.SetTabStops(60, New Single() {0})
If Mi.Enabled Then
br = New SolidBrush(Color.Black)
Else
br = New SolidBrush(Color.Gray)
End If
If (Mi.Text <> "-") Then
EvDrawItems.Graphics.DrawString(GetRealText(Mi), m_Font, br, _
EvDrawItems.Bounds.Left + 26, _
EvDrawItems.Bounds.Top + 6, sf)
Else
EvDrawItems.Graphics.DrawLine(New Pen(Color.Gray), rcBk.Left, rcBk.Top + 2, rcBk.Width - 4, rcBk.Top + 2)
End If
If (Mi.Index = 0) Then
ControlPaint.DrawBorder3D(EvDrawItems.Graphics, EvDrawItems.Bounds.Left, EvDrawItems.Bounds.Top, EvDrawItems.Bounds.Width, EvDrawItems.Bounds.Height, Border3DStyle.Flat, Border3DSide.Top Or Border3DSide.Left Or Border3DSide.Right)
Else
If Not (Mi.Parent Is Mi.GetMainMenu) Then
If (Mi.Parent.MenuItems.Count - 1 = Mi.Index) Then
ControlPaint.DrawBorder3D(EvDrawItems.Graphics, EvDrawItems.Bounds.Left, EvDrawItems.Bounds.Top, EvDrawItems.Bounds.Width, EvDrawItems.Bounds.Height, Border3DStyle.Flat, Border3DSide.Bottom Or Border3DSide.Left Or Border3DSide.Right)
Else
ControlPaint.DrawBorder3D(EvDrawItems.Graphics, EvDrawItems.Bounds.Left, EvDrawItems.Bounds.Top, EvDrawItems.Bounds.Width, EvDrawItems.Bounds.Height, Border3DStyle.Flat, Border3DSide.Left Or Border3DSide.Right)
End If
Else
If (Mi.GetMainMenu.MenuItems.Count - 1 = Mi.Index) Then
ControlPaint.DrawBorder3D(EvDrawItems.Graphics, EvDrawItems.Bounds.Left, EvDrawItems.Bounds.Top, EvDrawItems.Bounds.Width, EvDrawItems.Bounds.Height, Border3DStyle.Flat, Border3DSide.Bottom Or Border3DSide.Left Or Border3DSide.Right)
Else
ControlPaint.DrawBorder3D(EvDrawItems.Graphics, EvDrawItems.Bounds.Left, EvDrawItems.Bounds.Top, EvDrawItems.Bounds.Width, EvDrawItems.Bounds.Height, Border3DStyle.Flat, Border3DSide.Left Or Border3DSide.Right)
End If
End If
End If
br.Dispose()
br = Nothing
sf.Dispose()
sf = Nothing
End Sub
The warlord
|
|
|
|
|
Hi!
If it's possible, how do I remove scrollbar from tree view control?
(Done it with data grid, but tree view seems to contain no other controls)
/Rickard
|
|
|
|
|
Hello Friends, Please give me ideas on how to carry on my project. What software can I possibly use?
This is the requirement for my final yr project:
Project Title: E-commerce website design: shopping cart
Aim of project: A commercial website needs to develop a shopping cart for their online shop
Summary of work to be undertaken:
*investigate a current state of e-commerce technologies
*propose a basic plan of your design
* implement the design into a fully functional shopping cart
*implement a simple web page to show how to use your shopping cart.
*Write a report and present the final result
=======================
I would be extremely grateful if you could advise me on the right programs to use.Please send your responses to dubeben2002@yahoo.co.uk
|
|
|
|
|
i have a textbox control that displays a date field. In the validating event of the control, I am checking that the user has entered a valid date (in the format I specify and check), and if the date is not valid calling e.cancel = true to force valid date entry. My problem is that if the user trys to close the form using the X button, the validating event is still firing. I read somewhere you could check the mouse click to determine where the user clicked (title bar or client area). How would you determine where the user clicked?
jmiddleton
|
|
|
|
|
vb6 or vb.net ?
in vb6 i don't face this problem
|
|
|
|
|
|
|
How can I set a password on my source code so that no one can open a project?
|
|
|
|
|
Unless your using the Code Repository, you can't.
The Code Repository is like a library, where you check code in and out to work on it.
If your not using the Repository, then you'll have to depend on NTFS folder rights on your project to keep other users out of the folder.
|
|
|
|
|
Hi,
I use VS .NET (Version 1.0.30xxx) for the VB .NET development.
I tried to write my own class with its own properties and methods. And I was able to use them in the derived objects. This all works fine when it comes to programming.
For example....
<br />
<br />
public class MyOwnClass<br />
public sub MySubMethod()<br />
...<br />
end sub<br />
end class<br />
<br />
What should I do to get the comment/description in the IDE... when I keep the mouse over the method name, when invoking as....
<br />
dim myc as new MyOwnClass()<br />
myc.<br />
(Please ignore any errors if there is in code)
When I type that myc. dot... the list of methods in the class are displayed in the IDE... I want to see a description/comment - that says abou the methos nearby (this gets displayed in any inbuild methods in the class library)
Please help. I am sorry, if I was not able to explain my requirement properly.
I was born intelligent Education ruined me!.
|
|
|
|
|
|
Thanks.... I would give it a try..,
I was born intelligent Education ruined me!.
|
|
|
|
|
You might wa to try searching in the help for Visual Basic.NET for 'Attributes and Design-Time Support' for how to add descriptions to your code.
|
|
|
|
|
Anonymous wrote:
searching in the help for Visual Basic.NET
This didnt help me much.. thats why I was trying to get help from CP
I was born intelligent Education ruined me!.
|
|
|
|
|