473,506 Members | 16,951 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4843
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
9267
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
7
3414
by: Jared Evans | last post by:
I developed a console application that will continually check a message queue to watch for any incoming data that needs to be inserted into MS SQL database. What would be a low-cost method I...
2
2549
by: altergothen | last post by:
Hi there I am a newbie to ASP.Net - Please Help! I am trying to insert the values of my variables into a database. If I try the following it works perfectly: string insertQuery = "INSERT into...
6
2034
by: Pushpendra Vats | last post by:
Hi , I am trying to insert records into database. I am trying to write the following code. On button1 click event i am inserting five records and after that i am calling the update method of...
0
2990
by: pd123 | last post by:
I'm new to C# and .net and I'm trying to create a form that will register users in a sql server database. I have the following code but when I run the code I get an error " The name 'Peter' is...
3
3342
by: Surya | last post by:
Dear All, I have problem on inserting a record to database..Although it looked easy.. i have caught up with following issue .. please go ahead and help me to find solution I Need to insert...
2
5624
by: Ravigandha | last post by:
Hello everybody, My question is how to insert special characters and symbols in Mysql5 database and how to retrieve them from database in php. Here i am inserting some data from a form,by post...
6
1882
by: Bunty | last post by:
I want to insert values in the database.If i insert values one by one then it works till 4 or 5 fields then after it gives error.In my database there are more than 20 field.Pls help me.
2
3057
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
0
7103
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...
1
7021
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5614
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,...
1
5035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4701
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.