Inserting data to MS SQL Database

E

Etayki

Hi!

I am trying to insert data into a MS SQL Database from a Console
Application written in VB.net
I have already created the table in the database and I am able to read
values. When I insert a value using the Table Adapter's Query
"InsertQuery", I am able to see that the data was inserted during
runtime upon reading back the value that was inserted. However, when
the program is over I look at the database and see that the data row
has not been inserted.

Here is my code:

Module Module1

Sub Main()

' Here I am inserting a new record into the table (I am not
receiving any errors)
Dim DomainTableAdapter1 As
Database1DataSetTableAdapters.DomainTableTableAdapter
DomainTableAdapter1 = New
Database1DataSetTableAdapters.DomainTableTableAdapter()
DomainTableAdapter1.InsertQuery(3, "test", "Luz")

'Here I am reading the value that I just inserted to see that
it worked (and it does!)
Dim scalarQueriesTableAdapter As
Database1DataSetTableAdapters.DomainTableTableAdapter
scalarQueriesTableAdapter = New
Database1DataSetTableAdapters.DomainTableTableAdapter()
Dim returnValue As Integer
returnValue = CType(scalarQueriesTableAdapter.ScalarQuery(),
Integer)
Console.WriteLine(returnValue)

End Sub

End Module

' Now that the program is over I take a look at my database table but
I do not see the new record.

How do I fix this situation so that the data will be in the table
after the program is over? I have a feeling I am merely creating an
object (copy) of the database table but I am not actually working with
the original database table. Is this correct and what do I do to
rectify the situation?

Thanks
 
D

dbahooker

cute article, bro

would AOL or Google make this so difficult for real-world users?

it's a bug, it should be easier
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top