Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact
A1VBCode Forums
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      

Home » Visual Basic (VB 4/5/6) » Database Programming » save image in sql database


save image in sql databaseExpand / Collapse
Author
Message
Posted 6/14/2008 4:19:57 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 6/14/2008 4:13:09 PM
Posts: 2, Visits: 5
hi all

I am learning sql and i have created one small application with one table with ImageID and Pic as two columns, it works fine i can add new image in to database and i can also delete saved image from database, but main problem is when ever i made any changes to database it doesn't show any changes to form i mean it's not refreshing database or dataset

here is the few code for it

Private Sub LoadImages()

Try

conImage = GetDBConnection()

dsImage.Clear()

Me.daImage.Fill(Me.dsImage.Images)

Catch ex As Exception

MsgBox(ex.Message)

End Try

conImage.Close()

conImage.Dispose()

Call PoChng()

End Sub

 

this is for save and delete click event code

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

'get sql connection

Try

conImage = GetDBConnection()

Dim sSQL As String = "INSERT INTO Images (Pic) VALUES(@pic)"

commImage = New Data.SqlClient.SqlCommand(sSQL, conImage)

Call GetImage()

commImage.ExecuteNonQuery()

MessageBox.Show("Image successfuly saved in database", "Image Load")

Catch ex As Exception

MsgBox(ex.Message)

End Try

commImage.Dispose()

conImage.Close()

conImage.Dispose()

Call LoadImages()

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

SelectedImage = ("DELETE FROM Images WHERE ImageID = " & txtImageFile.Text)

conImage = GetDBConnection()

Try

commImage = New Data.SqlClient.SqlCommand(SelectedImage, conImage)

commImage.ExecuteNonQuery()

MsgBox("Image successfuly deleted from database", MsgBoxStyle.Information)

Catch ex As Exception

MsgBox(ex.Message)

End Try

commImage.Dispose()

commImage = Nothing

conImage.Close()

conImage.Dispose()

Call LoadImages()

End Sub

 

i am stuck with this since last 3 weeks any help

Post #25198
Posted 6/26/2008 9:06:30 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 6/27/2008 12:14:44 AM
Posts: 5, Visits: 14
Hello Bapu,

Your problem is the same as mine. I have reviewed your codes and I have noticed that we have different style in coding. But, I think you have missed one line in your codings. In your codes, I suggest that after you update your database just like deleting, adding and updating your pictures in your codes, just try to add this: “databasename.refresh”.It would more effective if you type it 5- 7 times.

There are many examples of it in your MSDN or download it in the internet.

I hope this could help you.



Ethan

Post #25312
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Brian, Peter

PermissionsExpand / Collapse

All times are GMT -5:00, Time now is 4:58am