Click here to Skip to main content

beniv asked:

Open original thread
my db table is tbltest with id(int),name(varchar),lastname(varchar),foto(datatype image)
i can insert data in my database but i don't now to update them
i have store data in my db ,and i will to update them with a button (update)
the code for my insert button is
 
cmdtabela1 = connetion.CreateCommand
                  cmdtabela1.CommandText = "insert into tbltest values (@name,@lastname,@foto) "
 
                  cmdtabela1.Parameters.AddWithValue("name", txtname.Text)
                  cmdtabela1.Parameters.AddWithValue("lastname", txtlastname.Text)
                  
 

                  Dim ms As New MemoryStream()
                  PictureBox1.BackgroundImage.Save(ms, PictureBox1.BackgroundImage.RawFormat)
                  Dim data As Byte() = ms.GetBuffer()
                  Dim p As New SqlParameter("foto", SqlDbType.Image)
                  p.Value = data
                  cmdtabela1.Parameters.Add(p)
 
now how to update this colums in my database
 
i have write this code for my update button
 
connetion = New SqlConnection("my conetion string")
                    connetion.Open()
 
                    Dim ms As New MemoryStream()
                    PictureBox3.BackgroundImage.Save(ms, PictureBox3.BackgroundImage.RawFormat)
                    Dim data As Byte() = ms.GetBuffer()
                    Dim p As New SqlParameter("Foto", SqlDbType.Image)
                    p.Value = data
                    cmdtabela.Parameters.Add(p)
 
                    cmdtabela = connetion.CreateCommand
                    cmdtabela.CommandText = "update tbltest set name='" & txtupdatename.Text & "', lastname='" & txtupdatelstname.Text &   where Id='" & Trim(txtid.Text) & "'"
Tags: VB.NET

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100