|
Hello,
You can have a look at this link. It will give you some idea.
http://www.devx.com/vb2themax/Tip/18742[^]
I hope this will help.
Regards,
Allen
Allen Smith
Software Engineer
ComponentOne LLC
www.componentone.com
|
|
|
|
|
i am going through that.
thanks for your help
|
|
|
|
|
i am using vb express 2005 edition.
vb6 is not installed in my computer.
|
|
|
|
|
i want to save image in db
i m using ms access db
images are stored in database successfully.
i have added a list box on the form and i want that when i save image in db so that image name should be added in list box
but i don't know how to do that
i m also giving code below
any body can help me.
thanks
Option Strict On
Imports System.Data.SqlClient
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Replace(Application.StartupPath, "bin", "") & "DB.mdb;Mode=ReadWrite;Persist Security Info=False")
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
Friend WithEvents PicBindingSource As System.Windows.Forms.BindingSource
Friend WithEvents OleDbConnection1 As System.Data.OleDb.OleDbConnection
Friend WithEvents OleDbDataAdapter1 As System.Data.OleDb.OleDbDataAdapter
Friend WithEvents OleDbInsertCommand1 As System.Data.OleDb.OleDbCommand
Friend WithEvents OleDbSelectCommand1 As System.Data.OleDb.OleDbCommand
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents DataSet11 As LoadinImages.DataSet1
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
Me.Label1 = New System.Windows.Forms.Label
Me.ListBox1 = New System.Windows.Forms.ListBox
Me.DataSet11 = New LoadinImages.DataSet1
Me.PicBindingSource = New System.Windows.Forms.BindingSource(Me.components)
Me.OleDbConnection1 = New System.Data.OleDb.OleDbConnection
Me.OleDbDataAdapter1 = New System.Data.OleDb.OleDbDataAdapter
Me.OleDbInsertCommand1 = New System.Data.OleDb.OleDbCommand
Me.OleDbSelectCommand1 = New System.Data.OleDb.OleDbCommand
Me.TextBox1 = New System.Windows.Forms.TextBox
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.DataSet11, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.PicBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Button1
'
Me.Button1.ForeColor = System.Drawing.Color.Black
Me.Button1.Location = New System.Drawing.Point(121, 376)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 23)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Browse"
'
'Button2
'
Me.Button2.ForeColor = System.Drawing.Color.Black
Me.Button2.Location = New System.Drawing.Point(220, 377)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(75, 23)
Me.Button2.TabIndex = 1
Me.Button2.Text = "Save"
'
'PictureBox1
'
Me.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.PictureBox1.Location = New System.Drawing.Point(24, 16)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(301, 304)
Me.PictureBox1.TabIndex = 3
Me.PictureBox1.TabStop = False
'
'Label1
'
Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.Label1.ForeColor = System.Drawing.Color.Red
Me.Label1.Location = New System.Drawing.Point(24, 341)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(427, 32)
Me.Label1.TabIndex = 4
'
'ListBox1
'
Me.ListBox1.BackColor = System.Drawing.SystemColors.Control
Me.ListBox1.HorizontalScrollbar = True
Me.ListBox1.Location = New System.Drawing.Point(331, 16)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.ScrollAlwaysVisible = True
Me.ListBox1.Size = New System.Drawing.Size(120, 303)
Me.ListBox1.TabIndex = 7
'
'DataSet11
'
Me.DataSet11.DataSetName = "DataSet1"
Me.DataSet11.Locale = New System.Globalization.CultureInfo("en-US")
Me.DataSet11.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
'
'PicBindingSource
'
Me.PicBindingSource.DataMember = "Pic"
Me.PicBindingSource.DataSource = Me.DataSet11
'
'OleDbConnection1
'
Me.OleDbConnection1.ConnectionString = resources.GetString("OleDbConnection1.ConnectionString")
'
'OleDbDataAdapter1
'
Me.OleDbDataAdapter1.InsertCommand = Me.OleDbInsertCommand1
Me.OleDbDataAdapter1.SelectCommand = Me.OleDbSelectCommand1
Me.OleDbDataAdapter1.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "Images", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("Filename", "Filename"), New System.Data.Common.DataColumnMapping("Photo", "Photo")})})
'
'OleDbInsertCommand1
'
Me.OleDbInsertCommand1.CommandText = "INSERT INTO Images(Filename, Photo) VALUES (?, ?)"
Me.OleDbInsertCommand1.Connection = Me.OleDbConnection1
Me.OleDbInsertCommand1.Parameters.AddRange(New System.Data.OleDb.OleDbParameter() {New System.Data.OleDb.OleDbParameter("Filename", System.Data.OleDb.OleDbType.VarWChar, 50, "Filename"), New System.Data.OleDb.OleDbParameter("Photo", System.Data.OleDb.OleDbType.VarBinary, 0, "Photo")})
'
'OleDbSelectCommand1
'
Me.OleDbSelectCommand1.CommandText = "SELECT Filename, Photo FROM Images"
Me.OleDbSelectCommand1.Connection = Me.OleDbConnection1
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(124, 406)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(171, 20)
Me.TextBox1.TabIndex = 8
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.Control
Me.ClientSize = New System.Drawing.Size(466, 438)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.ListBox1)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.PictureBox1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.ForeColor = System.Drawing.Color.White
Me.Name = "Form1"
Me.Text = "DataBase Images"
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.DataSet11, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.PicBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim thumbNail As Image
With OpenFileDialog1
.Filter = "All Files|*.*|Bitmaps|*.bmp|GIFs|*.gif|JPEGs|*.jpg"
.FilterIndex = 2
End With
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
With PictureBox1
.Image = Image.FromFile(Me.OpenFileDialog1.FileName)
.SizeMode = PictureBoxSizeMode.CenterImage
End With
Dim theImage As New Bitmap(OpenFileDialog1.FileName)
PictureBox1.Image = theImage
thumbNail = theImage.GetThumbnailImage(PictureBox1.Height, PictureBox1.Width, Nothing, Nothing)
PictureBox1.Image = thumbNail
End If
Me.Label1.Text = Me.OpenFileDialog1.FileName.ToString
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
On Error GoTo fix
If TextBox1.Text = "" Then
MsgBox("Please Enter Name File")
TextBox1.Focus()
Exit Sub
End If
' Open the file
Dim fs As FileStream = New FileStream(OpenFileDialog1.FileName, FileMode.Open, FileAccess.Read)
Dim s As String = TextBox1.Text
'Read the output in binary reader
Dim r As BinaryReader = New BinaryReader(fs)
'Declare a byte array to save the content of the file to be saved
Dim FileByteArray(CInt(fs.Length - 1)) As Byte
r.Read(FileByteArray, 0, CInt(fs.Length))
Dim sql As String = "INSERT INTO Images (Filename,Photo) VALUES (?,?)"
Dim i As Integer
ListBox1.Items.Add(TextBox1.Text)
MessageBox.Show("Image Succesfully inserted !", "Photo Album", MessageBoxButtons.OK, MessageBoxIcon.Information)
fix:
Exit Sub
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim arrayImage() As Byte = CType(Me.DataSet11.Tables(0).Rows(Me.ListBox1.SelectedIndex)("photo"), Byte())
Dim ms As New MemoryStream(arrayImage)
With Me.PictureBox1
.Image = Image.FromStream(ms)
.SizeMode = PictureBoxSizeMode.CenterImage
End With
End Sub
End Class
Aamir Mustafa
|
|
|
|
|
There's too much code here. Most of it is irrelevent to the problem at hand.
Identify which bit of code you need help with and post it only.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Seriously, your code is unreadable. Using default names like button1 and listview2, means I cannot scan this and have any idea what each method is supposed to do, without examining the code closely.
You're talking about listboxes, but the code you posted is putting the image in a picture box. Does this code work ? If so, there's no problem with your database, or any of the code you have posted.
If you just need to know how to show an image in a listbox, then you should probably look here[^].
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: Using default names like button1 and listview2
This is something I try to get my students to stay away from, and amazingly some still do it. Points get docked when it happens.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Thanks for the worthless code dump
Just post the code where you suspect the problem is occurring
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
i have been looking everywhere for help with this project please someone help me:
i want to create a program that would run on a pc (which would be connected to a blue tooth dongle) and would connect to a bluetooth cell phone. the program would send a text message and multiple cell phone numbers to the cell phone, and instruct the cell phone to send out that message to all the given cellphone numbers.
i cant afford to buy any api's (im a volunteer in africa doing hiv/aids work). if someone could just explain to me how to do this in vb.net (example code?) or at least tell me the step by step processes i would need to do, id appreciate it. also, if i need any dll or anything let me know. my deadline is quickly approaching to get this program done (and i just want to know)
im using visual basic 2005 express edition.
|
|
|
|
|
I'm not sure that a standard API exists to control a cell phone like that ? I'd have thought you'd do better to use a phone that is a Windows device and write a program for it, or research ways to send a text message via a webservice so you just needed to connect to the web, and not a cell phone ?
http://www.google.com.au/search?source=ig&hl=en&rlz=&q=send+sms+vb.net&meta=[^]
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
thanks for repplying. i cant send through the net. in botswana all cell phone services are prepaid. because of this, the companies do not give out there address to send the text messages. even if i could, im sure id be breaking some law. im sure theres a way. id imagine i would need the cellphones model number or something to connect to it. the usb dongle would be plug and play
|
|
|
|
|
The model number isn't going to help much, .NET doesn't have classes to talk to a mobile phone over bluetooth AFAIK. I assume you can connect to the web, or how are you able to post here ? If you can get on the web, then you can use a webservice that connects to an SMS provider.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
i have access to internet but the office im peploying the software to does not
|
|
|
|
|
Write it as a compact framework app and deploy it to a windows mobile phone. IIRC theres a free managed library around that does a fair bit of stuff like SMS.
|
|
|
|
|
that wont work either. i need to keep it pc side because i need to store all messages, timestamps, recipients, etc in a database for record keeping purposes.
|
|
|
|
|
i tried doing a cellphone connection using usb dongle way-back
think of it as trying to control a serial comm port and just try using the serial port in
.net class
the bluetooth is just a type of serial port so it works exactly like using a serial port
understand?tryna find my resources if i do, will post them here
but read on AT Command Set for serial modems
phatkin
|
|
|
|
|
hi,there
please i want a source code in vb.net that handle this situation :
" my application(pj) is runnig from usb flash memory and when i right click on any file in c:\ ,d:\ ,...
and do send to my flash memory , i want my running application(my project) to handle this case and puase the copying , and take the file path ,so that my application will deal with it "
forgive me for my poor eng language , i hope you understand
i wait for an answer
thanks.
|
|
|
|
|
Abdduke wrote: please i want a source code in vb.net that handle this situation :
You want someone to do your coursework so you can graduate? Don't you think that's a bit dishonest?
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
no i dont ,because i am working so hard on my project and i stuck on this functionality , and i refere to many doc. & profs. in my university ,they dont know how to do this , and tell me to learn form a good programmer or to read some books . the problem ,i dont know the subject or which book i have to read.
so , dont tell me that is dishonest.
if you do not want to help and learn other ,dont judge them.
|
|
|
|
|
It is dishonest to ask others to do your coursework and then claim the work as your own. Read the forum guidelines, paying specific attention to rules 2 & 9.
If you graduate based on someone else's work, you have deceived both yourself and your university. If you get a job based on a qualification you didn't deserve, are you going to continue to get other people to do your work for you? You won't be able to hide your lack of ability forever; you will be found out and probably fired.
I find it hard to believe that no one in your department can help you, unless you are attending a really poor university. Anyway, if you do ask for help on CodeProject, make your questions more specific. People will be happy to offer assistance with particular problems, but no one will give you a complete solution. This forum is for people who want to learn, not for the lazy and/or stupid.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
pmarfleet wrote: find it hard to believe that no one in your department can help you
Same here.
pmarfleet wrote: attending a really poor university
Probably some no-accredited institution. You get what you pay for.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
pmarfleet wrote: You want someone to do your coursework so you can graduate?
He probably does. It's probably a bit of laziness, incompetence, or a mixture of both.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Abdduke wrote: i want a source code in vb.net that handle this situation
Do your own work. If someone supplies you with source code how to do this, then there are some questions to ask:
1. How do you feel about doing dishonest work?
2. How do you expect to work on real, challenging tasks that await in software development if you can't do something simple like this?
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Well,it seems my subject "Please help with my....." or maybe "i want a source code in vb.net that handle this...." break me down or make it a dishonest ask.
1. First of all,my project is almost finished and this functionality that i asked ,well not fail my project that is my doc. told me your project is fine and you do not need it badly.but when i alwayse do a job i do it better.and you know i am a student in SE. ,we focus on project documentation,analysis and design.we are not very good in programming.
2. as you know i will finish my studying stage after 3 months from now,and i have to practice about 6 months in any company that my university has a contract with it.
so i will get experience in time.and you know SE. is a practical work.
you know about Extreme programming method and its gouls and other SW devlopment approches. and one of some companies standards and qualities to get new developer in developing new project to get him learn form them......
finally, this is the last reply on this subject.my first reply i asked a source code (may too much asking)couse i am bad in express in Eng. i dont know how did you get it.
but my secod reply,i had explained my setuation and asked if you know a clue or abook to read about the subject.
becouse this is new for me and have not leard before.it is simple work for you but it is new to me.not i am lazy or i want other do my own work
so in this reply, i will ask nothing.
but let me ask you a question :
how do you learnd ? maybe someone have teach you(in sch. or university)
or maybe you had learned from book(auther teach you).
or why people vist this site ? maybe they want to learn!
even though i ask nothing.
thanks any way .
|
|
|
|
|
Hi,
I hope to get some advice on how best to proceed with the problem highlighted below:
I have written a windows application in VB .Net that connects to a commercial web service and retrieves data. There are a number of different calls that can be made to this web service depending upon the type of data to be retrieved.
The app can spawn many worker threads that can each make separate calls to the web service over a very short timespan.
I have not had any problems with api call limits until recently when the commercial organisation hosting the web servce has introduced financial penalties for exceeding a predefined api call limit over a moving window. For example if more than say 5 api calls are made over a 1 second window a charge will be levied on all subsequent calls made within that window above the 5 call limit.
What I would like to do therefore is introduce some sort of queuing system that all these threads are able to hook into that is able to check if the limit has been exceeded and if not allow the call through or block the call until the number of calls are below the limit for the moving window. The queued calls will be first-in-first-out.
What I really need to know though is how do I ensure that once a call is allowed through and data is retrieved from the web service how do I make sure that the correct data is returned to the correct thread given that the many different threads may be making the same call (but with different parameters and therefore returning a unique dataset)?
I hop this is clear and many thanks for your help in advance!
|
|
|
|
|