473,387 Members | 3,810 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,387 software developers and data experts.

[vb8] Add NewRow to .mdb problems

Hi there,
hoping somebody can help out here. Searched half earth to find a
solution but no success yet. The following code doesn't gave any fault
or warning but doesn't what it is suppose to do.
Can somebody explain why this code does not produce an extra new row in
my database?

Thanks, Nico
************************************************** **********************
Imports System.Data.OleDb

Public Class Form1
Inherits System.Windows.Forms.Form
Dim VarDataAdapter As New OleDbDataAdapter()
Dim VarConnection As New OleDbConnection()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

VarConnection.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=PetChamp.mdb;User
Id=admin;Password=;"
VarDataAdapter.SelectCommand = New OleDbCommand("SELECT * FROM
Omzet")
VarDataAdapter.SelectCommand.Connection = VarConnection

Dim newRow As PetChampDataSet.OmzetRow =
Me.PetChampDataSet1.Omzet.NewRow()
newRow.Artikel = "Muis met staart"
newRow.EANcode = "123"
Me.PetChampDataSet1.Omzet.Rows.Add(newRow)
OmzetTableAdapter.Update(PetChampDataSet1)
End Sub

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
'PetChampDataSet1.Omzet' table. You can move, or remove it, as needed.
Me.OmzetTableAdapter.Fill(Me.PetChampDataSet1.Omze t)
End Sub
Oct 25 '07 #1
1 1398
Pitmaster schreef:
Hi there,
hoping somebody can help out here. Searched half earth to find a
solution but no success yet. The following code doesn't gave any fault
or warning but doesn't what it is suppose to do.
Can somebody explain why this code does not produce an extra new row in
my database?

Thanks, Nico
************************************************** **********************
Imports System.Data.OleDb

Public Class Form1
Inherits System.Windows.Forms.Form
Dim VarDataAdapter As New OleDbDataAdapter()
Dim VarConnection As New OleDbConnection()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

VarConnection.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=PetChamp.mdb;User
Id=admin;Password=;"
VarDataAdapter.SelectCommand = New OleDbCommand("SELECT * FROM
Omzet")
VarDataAdapter.SelectCommand.Connection = VarConnection

Dim newRow As PetChampDataSet.OmzetRow =
Me.PetChampDataSet1.Omzet.NewRow()
newRow.Artikel = "Muis met staart"
newRow.EANcode = "123"
Me.PetChampDataSet1.Omzet.Rows.Add(newRow)
OmzetTableAdapter.Update(PetChampDataSet1)
End Sub

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
'PetChampDataSet1.Omzet' table. You can move, or remove it, as needed.
Me.OmzetTableAdapter.Fill(Me.PetChampDataSet1.Omze t)
End Sub
You're adding a new row to the dataset (which just holds the result of
your query), not to the mdb file. You'll need to use an insert query to
add a new row to the database. I.e.: "insert into omzet..." etc. and
then execute that query on the database.

--
Rinze van Huizen
C-Services Holland b.v
Oct 25 '07 #2

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

Similar topics

1
by: Al Bastido via .NET 247 | last post by:
could somebody please explain to me how the datatable.newrow method works, i've been trying to figure it out for weeks. I need to emulate it myself. I can bind my datagrid to a collection of...
7
by: Jason Callas | last post by:
I have a process that manages a list of trades. Each trade is a separate row in the table. I blast the process with 10,000 new trades in order to stress test it and end up with the below listed...
1
by: Piyush Gupta | last post by:
Hi All, I am using following code snippet to add another user in Users.xml: ------------------------------------------------------------------- DataSet dstUsers = new DataSet();...
1
by: Tomas R | last post by:
I have a datagrid with a dataview(created from a DataTable) bind to it. It displayes coordinates and I have a toolbarbutton that will create a set of new coordinates just like the existing ones,...
14
by: Agnes | last post by:
I only one datagrid, and one button. the buttonwill process ' dtmyTable.newrow()' , However, the datagrid seems didn't add the row byitself ?? Thanks
1
by: smith | last post by:
Sometimes you just notice something neat ... You may already know this but my googling didn't show it as having been mentioned and I thought it deserved it. If you're like me and tried the...
2
by: Dick Monahan | last post by:
I have a little VB6 program that dumps the schema of an Access 97 database. The following lines of code are relevant. Private m_wsDb As DAO.Workspace Private m_db As DAO.Database Set m_wsDb =...
1
by: jhansen | last post by:
I am having problems with my datagridview adding an extra blank row. I allow the user to enter a row of data, and based upon business rules, I add additional rows in the following manner. What...
2
by: ERNESTP | last post by:
Hi all, I am starting to learn how to program VB.Net and I found got an problem when try to insert a new row into the table. I had create an form to whole all the DataSet, OleDbDataAdaper and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.