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

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 4834
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
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
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
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
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
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
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
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
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
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.