469,613 Members | 2,114 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,613 developers. It's quick & easy.

Inserting data to MS SQL Database

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.DomainTableTableAdap ter
DomainTableAdapter1 = New
Database1DataSetTableAdapters.DomainTableTableAdap ter()
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.DomainTableTableAdap ter
scalarQueriesTableAdapter = New
Database1DataSetTableAdapters.DomainTableTableAdap ter()
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

Apr 17 '07 #1
2 4708
Etayki,

Could be this:

http://msdn2.microsoft.com/en-us/library/ms246989.aspx

Kerry Moorman
"Etayki" wrote:
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.DomainTableTableAdap ter
DomainTableAdapter1 = New
Database1DataSetTableAdapters.DomainTableTableAdap ter()
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.DomainTableTableAdap ter
scalarQueriesTableAdapter = New
Database1DataSetTableAdapters.DomainTableTableAdap ter()
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

Apr 17 '07 #2
cute article, bro

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

it's a bug, it should be easier


On Apr 17, 4:12 pm, Kerry Moorman
<KerryMoor...@discussions.microsoft.comwrote:
Etayki,

Could be this:

http://msdn2.microsoft.com/en-us/library/ms246989.aspx

Kerry Moorman

"Etayki" wrote:
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.DomainTableTableAdap ter
DomainTableAdapter1 = New
Database1DataSetTableAdapters.DomainTableTableAdap ter()
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.DomainTableTableAdap ter
scalarQueriesTableAdapter = New
Database1DataSetTableAdapters.DomainTableTableAdap ter()
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- Hide quoted text -

- Show quoted text -

Apr 18 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by altergothen | last post: by
6 posts views Thread by Pushpendra Vats | last post: by
6 posts views Thread by Bunty | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.