473,396 Members | 1,760 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,396 software developers and data experts.

Database Saving

I have a vb 2005 program that I am writing. It is just a form with a
datagridview, textbox, and import command button. The code looks like
this:

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
'TestDbDataSet.TestTable' table. You can move, or remove it, as
needed.
Me.TestTableTableAdapter.Fill(Me.TestDbDataSet.Tes tTable)
End Sub

Private Sub cmdImport_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdImport.Click
Dim col1, col2 As String
Dim NewRow As DataRow
NewRow = TestDbDataSet.Tables(0).NewRow
col1 = txtImport.Text
col2 = txtImport.Text
NewRow.Item("Data1") = col1
NewRow.Item("Data2") = col2
Try
TestDbDataSet.Tables(0).Rows.Add(NewRow)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Private Sub TestTableBindingNavigatorSaveItem_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
TestTableBindingNavigatorSaveItem.Click
Me.Validate()
Me.TestTableBindingSource.EndEdit()
Me.TestTableTableAdapter.Update(Me.TestDbDataSet.T estTable)

End Sub
--------------------------------------------------------------------------------------------------------------------------------

It successfully adds rows to the datagridview control on the form.
However, it does not actually save the data into the access database
that I have created. When I open the database in Access after saving
the data in my application it is not present in the table. Nor is it
present when I close the application and then open it again. Can you
actually save the data entered in a vb 2005 independent windows
application to a previously created database? Or, does it just update
the control on the form making it look like it updated the database
table? Help would be greatly appreciated!

Aug 1 '07 #1
1 2060
nmrpa,

The oposite from the Fill is the Update.
Beside that you needs the update commands which are standard in a Fill
command, therefore you can use the commandbuilder.

I think that this sample reach very much your question, be aware that this
is a very SQL intensive sample, only ment as sample, not to use it that way.

http://www.vb-tips.com/SQLServerUpdate.aspx

Cor
<nm********@gmail.comschreef in bericht
news:11**********************@k79g2000hse.googlegr oups.com...
>I have a vb 2005 program that I am writing. It is just a form with a
datagridview, textbox, and import command button. The code looks like
this:

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
'TestDbDataSet.TestTable' table. You can move, or remove it, as
needed.
Me.TestTableTableAdapter.Fill(Me.TestDbDataSet.Tes tTable)
End Sub

Private Sub cmdImport_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdImport.Click
Dim col1, col2 As String
Dim NewRow As DataRow
NewRow = TestDbDataSet.Tables(0).NewRow
col1 = txtImport.Text
col2 = txtImport.Text
NewRow.Item("Data1") = col1
NewRow.Item("Data2") = col2
Try
TestDbDataSet.Tables(0).Rows.Add(NewRow)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Private Sub TestTableBindingNavigatorSaveItem_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
TestTableBindingNavigatorSaveItem.Click
Me.Validate()
Me.TestTableBindingSource.EndEdit()
Me.TestTableTableAdapter.Update(Me.TestDbDataSet.T estTable)

End Sub
--------------------------------------------------------------------------------------------------------------------------------

It successfully adds rows to the datagridview control on the form.
However, it does not actually save the data into the access database
that I have created. When I open the database in Access after saving
the data in my application it is not present in the table. Nor is it
present when I close the application and then open it again. Can you
actually save the data entered in a vb 2005 independent windows
application to a previously created database? Or, does it just update
the control on the form making it look like it updated the database
table? Help would be greatly appreciated!
Aug 2 '07 #2

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

Similar topics

11
by: HolaGoogle | last post by:
hi all, can you please tell me what i should do to avoid session timeout when displaying my database info in my asp form (DisplayUserDatabase.asp)??? ** actualy it does load and display the...
2
by: Roy Gourgi | last post by:
Hi, Is it possible to save to a database as opposed to saving to a flat .txt file? It could be any database program, such as FoxPro (preferably), SQL Server, MySQL. Furthermore, I would also...
3
by: nicole | last post by:
Hi, I really need help and or an explanation. I am working on a database to complete orders with confirmation, bills, .... everything is working pretty fine and in the end the size of the...
0
by: Tommy Christian | last post by:
Hi! Anyone who knows about saving serialized data to database, coz I have a problem with that. If I just serialize my session data and then deserialize it, it works. But when I save it...
3
by: Tony Lugg | last post by:
I have an application with a document management form. When users add documents to the form, I call the API function SHGetFileInfo to get the associated large and small icons for the file. These...
4
by: Jager | last post by:
Ok, I've got a program I am working on that is supposed to save all changes to the dataset to the actual database, but this doesn't seem to be working. I used the DataAdapter.Update(DataSet)...
2
by: nacho222 | last post by:
I'm currently in the middle of writing a persistence framework, and I have to make a design decission. The framework will take care of all the saving and restoring objects, and also the...
3
by: sameer | last post by:
Hi all, ..net framwork 1.1 sql server 2000 I have a vb.net winforms application using webservices\ remoting to upload documents\ images to the webserver and i am gong to store them in the sql...
0
by: sameer | last post by:
Hi all, ..net framwork 1.1 sql server 2000 I have a vb.net winforms application using webservices\ remoting to upload documents\ images to the webserver and i am gong to store them in the sql...
2
by: keerthisreenu | last post by:
hai to all...!! iam working with Ms Access 2000. iam saving an image in the database. After that i want to retrive the same image from database and displaying it in the picture box. but its not...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.