| | | Forum 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()TryconImage = GetDBConnection() dsImage.Clear() Me.daImage.Fill(Me.dsImage.Images)Catch ex As ExceptionMsgBox(ex.Message) End TryconImage.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 connectionTryconImage = 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 ExceptionMsgBox(ex.Message) End TrycommImage.Dispose() conImage.Close()conImage.Dispose() Call LoadImages()End SubPrivate Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.ClickSelectedImage = ( "DELETE FROM Images WHERE ImageID = " & txtImageFile.Text)conImage = GetDBConnection() TrycommImage = New Data.SqlClient.SqlCommand(SelectedImage, conImage)commImage.ExecuteNonQuery() MsgBox( "Image successfuly deleted from database", MsgBoxStyle.Information)Catch ex As ExceptionMsgBox(ex.Message) End TrycommImage.Dispose() commImage = NothingconImage.Close() conImage.Dispose() Call LoadImages()End Sub i am stuck with this since last 3 weeks any help  |
| | | | Forum 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 
|
| |
|
|