473,320 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Adding data to database

Hello
I am currently learning VB.net and I am using the tutorial on VB
express. One of the tutorials is about adding a database and then
creating a visual input or amendment screen but event though I have
followed the tutorial and even redone all the steps I cannot get the
input to save into the data below is the code that currently exists
against the form.

Public Class Form1

Private Sub AddressBookBindingNavigatorSaveItem_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
AddressBookBindingNavigatorSaveItem.Click
Me.Validate()
Me.AddressBookBindingSource.EndEdit()

Me.AddressBookTableAdapter.Update(Me.Database1Data Set.AddressBook)
End Sub

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

Me.AddressBookBindingSource.EndEdit()

Me.AddressBookTableAdapter.Update(Me.Database1Data Set.AddressBook)
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the
'Database1DataSet.AddressBook' table. You can move, or remove it, as
needed.

Me.AddressBookTableAdapter.Fill(Me.Database1DataSe t.AddressBook)

End Sub
End Class

Mar 14 '06 #1
4 1555
On 14 Mar 2006 06:16:40 -0800, "tr************@za.syspro.com"
<tr************@za.syspro.com> wrote:
Hello
I am currently learning VB.net and I am using the tutorial on VB
express. One of the tutorials is about adding a database and then
creating a visual input or amendment screen but event though I have
followed the tutorial and even redone all the steps I cannot get the
input to save into the data below is the code that currently exists
against the form.

Public Class Form1

Private Sub AddressBookBindingNavigatorSaveItem_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
AddressBookBindingNavigatorSaveItem.Click
Me.Validate()
Me.AddressBookBindingSource.EndEdit()

Me.AddressBookTableAdapter.Update(Me.Database1Dat aSet.AddressBook)
End Sub

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

Me.AddressBookBindingSource.EndEdit()

Me.AddressBookTableAdapter.Update(Me.Database1Dat aSet.AddressBook)
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the
'Database1DataSet.AddressBook' table. You can move, or remove it, as
needed.

Me.AddressBookTableAdapter.Fill(Me.Database1DataS et.AddressBook)

End Sub
End Class

Run the .exe file in the project's bin\debug folder a couple of times.
You should see saved changes.

The two lines in the FormClosing event are not necessary.

Gene
Mar 14 '06 #2
Hello Gene
Thank you for the help but could you probably give me a short
explaination as to why if I run the exe from with the bin/debug folder
will the changes be saved whereas if I do this from within the IDE the
changes do not get saved?
I did read something about the properties option to copy to output
directory that will allow the changes to be saved.

Mar 15 '06 #3
On 15 Mar 2006 03:48:17 -0800, "tr************@za.syspro.com"
<tr************@za.syspro.com> wrote:
Hello Gene
Thank you for the help but could you probably give me a short
explaination as to why if I run the exe from with the bin/debug folder
will the changes be saved whereas if I do this from within the IDE the
changes do not get saved?
I did read something about the properties option to copy to output
directory that will allow the changes to be saved.


The changes do actually get saved when running from within the IDE.
However, by default, the database file's property, Copy To Output
Directory, is "Copy Always". So, each time you run the project in the
IDE, the last working database file in the bin/debug folder gets
overwritten with the original database file, hence, it appears that
previous changes were not saved. The same applies with builds. Each
time you make a build, the original database file is copied to the
bin/release folder.

Changing "Copy Always" to Copy If Newer" will allow saved changes to
show when running in the IDE unless changes are made to the original
database file. If you are going to distribute the app, you need to
keep in mind whether you want the original or "current" database file
in the release.

Gene
Mar 15 '06 #4
Hello Gene
I do understand the concept and I have got it to work and as you
mentioned in your last statement the original database is being viewed
instead of the current. How can I change this?
Thanks for you time and help.

Mar 16 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Bobbak | last post by:
Hello All, I have these tables (lets call it ‘EmpCalls', ‘EmpOrders', and ‘Stats') that each contain the list of EmployeeIDs, I want to be able to create a Module in which I could call in my VB...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
3
by: Robin Thomas | last post by:
I am fairly new to ASP.NET so I think I am missing something fundamental. Anyway, quite often I am pulling data from a database, but then I need to use that data to produce more data. A simple...
1
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple...
10
by: Trevor | last post by:
Hey, I am trying to do this tutorial on the microsoft site : http://msdn.microsoft.com/library/default.asp? url=/library/en-us/dndotnet/html/usingadonet.asp I can get everything to work up to...
5
by: Neo Geshel | last post by:
Greetings. I am in a very big pickle. I am trying to add page content - as well as a submit button - programatically to a web form that is supposed to submit to DB and then refresh. That...
9
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT...
12
by: JMO | last post by:
I can import a csv file with no problem. I can also add columns to the datagrid upon import. I want to be able to start importing at the 3rd row. This will pick up the headers necessary for the...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
0
by: ganesh22 | last post by:
Hi... Iam using GridView in asp.net(2.0) .My requirement is user can add,update,delete in gridview I written the code for add & update but can u help adding rows in grid view My code: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.