aspnovice
12-10-2005, 10:48 PM
Hi Guys,
This is a follow up from my last post but is a different issue so I have started a new thread.
I have been following a tutorial in a book Vb 2005 Jumpstart Ch 4
Anyway I have followed the books code exactly and the program runs.
It connects to Amazons web service and allows the user to search and display books, the application also allows the user to save the titles that they wish by clicking an Add Title button, when the user does this the current focus title is saved to the database and can be viewed off line.
When I hit the add title the record gets saved as I can hit the catalog button which opens a new form with a datagrid that has all the titles I just saved in it!! GREAT!!
But when I close the app and run it again the catalog is gone?? back to no records again?
Now ive never worked with SQL databases before and this is me just having a go at .Net so I have no idea whats wrong or where to look.
Here is the code I have that inserts the data when the Add Title button is clicked
Public Sub AddTitle()
Try
'---get the book cover image as a byte array---
Dim ms As New System.IO.MemoryStream()
picCover.Image.Save(ms, picCover.Image.RawFormat)
Dim coverimage() As Byte = ms.GetBuffer
ms.Close()
'Double.Parse(txtPrice.Text)
txtPrice.Text = Strings.Replace(txtPrice.Text, "$", "")
txtPrice.Text = Strings.Replace(txtPrice.Text, "£", "")
'---add the new title to the database---
TitlesTableAdapter.Insert(lblISBN.Text, _
txtTitle.Text, txtAuthors.Text, _
txtPublisher.Text, txtPrice.Text, coverimage)
ToolStripStatusLabel1.Text += " - Added"
Catch ex As Exception
DisplayError("Error adding title. - " & ex.Message)
End Try
End Sub
I thought adding something like this would work, but alas it is not!!
TitlesTableAdapter.Update(LibraryDataSet)
Any help is greatly appreciated.
Thanks again
colin
This is a follow up from my last post but is a different issue so I have started a new thread.
I have been following a tutorial in a book Vb 2005 Jumpstart Ch 4
Anyway I have followed the books code exactly and the program runs.
It connects to Amazons web service and allows the user to search and display books, the application also allows the user to save the titles that they wish by clicking an Add Title button, when the user does this the current focus title is saved to the database and can be viewed off line.
When I hit the add title the record gets saved as I can hit the catalog button which opens a new form with a datagrid that has all the titles I just saved in it!! GREAT!!
But when I close the app and run it again the catalog is gone?? back to no records again?
Now ive never worked with SQL databases before and this is me just having a go at .Net so I have no idea whats wrong or where to look.
Here is the code I have that inserts the data when the Add Title button is clicked
Public Sub AddTitle()
Try
'---get the book cover image as a byte array---
Dim ms As New System.IO.MemoryStream()
picCover.Image.Save(ms, picCover.Image.RawFormat)
Dim coverimage() As Byte = ms.GetBuffer
ms.Close()
'Double.Parse(txtPrice.Text)
txtPrice.Text = Strings.Replace(txtPrice.Text, "$", "")
txtPrice.Text = Strings.Replace(txtPrice.Text, "£", "")
'---add the new title to the database---
TitlesTableAdapter.Insert(lblISBN.Text, _
txtTitle.Text, txtAuthors.Text, _
txtPublisher.Text, txtPrice.Text, coverimage)
ToolStripStatusLabel1.Text += " - Added"
Catch ex As Exception
DisplayError("Error adding title. - " & ex.Message)
End Try
End Sub
I thought adding something like this would work, but alas it is not!!
TitlesTableAdapter.Update(LibraryDataSet)
Any help is greatly appreciated.
Thanks again
colin