Click here to Skip to main content
15,894,410 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: please help me!! how to create MS access Databse and Table through VB 6.0 [modified] Pin
Kschuler26-May-06 4:59
Kschuler26-May-06 4:59 
QuestionNeed help permanently maintaining the rectangle after a button click Pin
iamsupersuperman25-May-06 18:14
iamsupersuperman25-May-06 18:14 
AnswerRe: Need help permanently maintaining the rectangle after a button click Pin
arcticbrew25-May-06 18:46
arcticbrew25-May-06 18:46 
GeneralRe: Need help permanently maintaining the rectangle after a button click Pin
iamsupersuperman25-May-06 20:32
iamsupersuperman25-May-06 20:32 
GeneralRe: Need help permanently maintaining the rectangle after a button click Pin
arcticbrew27-May-06 10:29
arcticbrew27-May-06 10:29 
Questionbinding pictures to database Pin
kids1725-May-06 12:20
kids1725-May-06 12:20 
AnswerRe: binding pictures to database Pin
Mekong River25-May-06 16:01
Mekong River25-May-06 16:01 
AnswerRe: binding pictures to database Pin
Guerven25-May-06 21:08
Guerven25-May-06 21:08 
you can convert an image to a stream then store it to an access database

Dim ms As New MemoryStream<br />
     PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)<br />
     Dim imageX() As Byte = ms.GetBuffer<br />
     ms.Close()<br />


After this step you already have an image in bytes() - imageX

Now.. assuming you have an access database with three fields. Message, Name, and PiC (pic is an OLE Object in access)

You need to use an OledbCommand's Parameter to pass the values correctyl.
here's How to Do it.
<br />
       oledbcommand1.Parameters.Clear()<br />
       oledbcommand1.Parameters.Add(New OleDbParameter("@MESSAGE", OleDbType.WChar, 50)).Value = TextBox1.Text<br />
       oledbcommand1.Parameters.Add(New OleDbParameter("@NAME", OleDbType.WChar, 50)).Value = TextBox2.Text<br />
       oledbcommand1.Parameters.Add(New OleDbParameter("@PIC", OleDbType.Binary)).Value = image<br />
       If VEN.Insert("INSERT INTO  Table1 ( MESSAGE , NAME1 , PIC ) VALUES (  ?  ,  ?  ,  ? )") = 1 Then<br />
           MessageBox.Show("Record Save!")<br />
           Me.Close()<br />
       End If<br />


ofcourse you need to setup a connection to an access database.
only images added trhough this method can be retireived.

to retrieve the image you need to reverse the step
<br />
            Dim i As Integer<br />
            If IsDBNull(TABLE.Rows(ROW)(iFIELD)) Then<br />
                MsgBox("You Tried to View an Image from an empty record", MsgBoxStyle.OKOnly, "Unable to Display Image")<br />
                Exit Sub<br />
            End If<br />
            Dim arrPicture() As Byte = CType(TABLE.Rows(ROW)("PIC"),byte())<br />
            Dim ms As New MemoryStream(arrPicture)<br />
            picturebox1.image = System.Drawing.Image.FromStream(ms)<br />
<br />



GUERVEN
Truth or Consequence
QuestionActive Directory Account for Querying... Pin
bighossman25-May-06 11:28
bighossman25-May-06 11:28 
Questioncan you tell me how to compare two DataTables ? [modified] Pin
Mohammed Amine25-May-06 11:20
Mohammed Amine25-May-06 11:20 
AnswerRe: can you tell me how to compare two DataTables ? [modified] Pin
Mekong River25-May-06 16:05
Mekong River25-May-06 16:05 
GeneralRe: can you tell me how to compare two DataTables ? [modified] Pin
Mohammed Amine26-May-06 0:21
Mohammed Amine26-May-06 0:21 
Questionview borders Pin
EddieHarary25-May-06 9:50
EddieHarary25-May-06 9:50 
AnswerRe: view borders Pin
Cliff Wellman25-May-06 11:01
Cliff Wellman25-May-06 11:01 
QuestionUsing Oracle Bind Variables in VB 6 [modified] Pin
Cliff Wellman25-May-06 8:28
Cliff Wellman25-May-06 8:28 
QuestionFOR TO NEXT - LOOP Question Pin
huertj25-May-06 4:46
huertj25-May-06 4:46 
AnswerRe: FOR TO NEXT - LOOP Question Pin
Guffa25-May-06 5:25
Guffa25-May-06 5:25 
AnswerRe: FOR TO NEXT - LOOP Question Pin
arcticbrew25-May-06 7:16
arcticbrew25-May-06 7:16 
AnswerRe: FOR TO NEXT - LOOP Question Pin
huertj26-May-06 4:41
huertj26-May-06 4:41 
QuestionMMC - OCX Page Alignment Pin
YemShivaKumar25-May-06 4:18
YemShivaKumar25-May-06 4:18 
QuestionText only in a textbox Pin
ADY00725-May-06 3:57
ADY00725-May-06 3:57 
AnswerRe: Text only in a textbox Pin
space_doggy25-May-06 5:53
space_doggy25-May-06 5:53 
AnswerRe: Text only in a textbox [modified] Pin
Robo1625-May-06 23:50
Robo1625-May-06 23:50 
AnswerRe: Text only in a textbox [modified] Pin
Mohammed Amine26-May-06 2:05
Mohammed Amine26-May-06 2:05 
Questioncreate runtime odbc for SQL Server Pin
vipinpaliwal198025-May-06 2:46
vipinpaliwal198025-May-06 2:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.