473,553 Members | 3,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataAdapter Update

Jon
Hi,

I have a function to fill the data into the dataset:

Private Sub LoadSystemDataD B(ByVal m_str As String, ByVal da As _
OleDbDataAdapte r, ByVal tbName As String)
Dim OleDbConn As New OleDbConnection (OLEDB_CONNECTI ON_1)
OleDbConn.Open( )
da = New OleDbDataAdapte r(m_str, OleDbConn)
Dim cmd As New OleDbCommandBui lder(da)
da.Fill(dsDataS et, tbName)
dsDataSet.CaseS ensitive = True
OleDbConn.Close ()
End Sub

However when i try to update the data using:
Dim autogen As New OleDbCommandBui lder(daLoginDet ails)
daDataAdapter.U pdate(dsDataSet , "myTable")

I get error when i try to update it. The error is on the Update line where
it saids "The DataAdapter.Sel ectCommand property needs to be initialized".

So i guess i was doing something wrong when filling the data??
or what is the proper way to make a fill data function? as i have many
tables to load into the dataset.

Hope anyone can help?
many thanks.
Nov 21 '05 #1
9 8394
Try something like this:

da.SelectComman d = cmd
da.Fill(dsDataS et, tbName)
"Jon" wrote:
Hi,

I have a function to fill the data into the dataset:

Private Sub LoadSystemDataD B(ByVal m_str As String, ByVal da As _
OleDbDataAdapte r, ByVal tbName As String)
Dim OleDbConn As New OleDbConnection (OLEDB_CONNECTI ON_1)
OleDbConn.Open( )
da = New OleDbDataAdapte r(m_str, OleDbConn)
Dim cmd As New OleDbCommandBui lder(da)
da.Fill(dsDataS et, tbName)
dsDataSet.CaseS ensitive = True
OleDbConn.Close ()
End Sub

However when i try to update the data using:
Dim autogen As New OleDbCommandBui lder(daLoginDet ails)
daDataAdapter.U pdate(dsDataSet , "myTable")

I get error when i try to update it. The error is on the Update line where
it saids "The DataAdapter.Sel ectCommand property needs to be initialized".

So i guess i was doing something wrong when filling the data??
or what is the proper way to make a fill data function? as i have many
tables to load into the dataset.

Hope anyone can help?
many thanks.

Nov 21 '05 #2
Try placing a

da.SelectComman d = cmd

just prior to your fill statement.
"Jon" wrote:
Hi,

I have a function to fill the data into the dataset:

Private Sub LoadSystemDataD B(ByVal m_str As String, ByVal da As _
OleDbDataAdapte r, ByVal tbName As String)
Dim OleDbConn As New OleDbConnection (OLEDB_CONNECTI ON_1)
OleDbConn.Open( )
da = New OleDbDataAdapte r(m_str, OleDbConn)
Dim cmd As New OleDbCommandBui lder(da)
da.Fill(dsDataS et, tbName)
dsDataSet.CaseS ensitive = True
OleDbConn.Close ()
End Sub

However when i try to update the data using:
Dim autogen As New OleDbCommandBui lder(daLoginDet ails)
daDataAdapter.U pdate(dsDataSet , "myTable")

I get error when i try to update it. The error is on the Update line where
it saids "The DataAdapter.Sel ectCommand property needs to be initialized".

So i guess i was doing something wrong when filling the data??
or what is the proper way to make a fill data function? as i have many
tables to load into the dataset.

Hope anyone can help?
many thanks.

Nov 21 '05 #3
Jon
typo error:
Instead of
daDataAdapter.U pdate(dsDataSet , "myTable")

It should be:
daLoginDetails. Update(dsDataSe t, "myTable")

can anyone help please?
"Jon" wrote:
Hi,

I have a function to fill the data into the dataset:

Private Sub LoadSystemDataD B(ByVal m_str As String, ByVal da As _
OleDbDataAdapte r, ByVal tbName As String)
Dim OleDbConn As New OleDbConnection (OLEDB_CONNECTI ON_1)
OleDbConn.Open( )
da = New OleDbDataAdapte r(m_str, OleDbConn)
Dim cmd As New OleDbCommandBui lder(da)
da.Fill(dsDataS et, tbName)
dsDataSet.CaseS ensitive = True
OleDbConn.Close ()
End Sub

However when i try to update the data using:
Dim autogen As New OleDbCommandBui lder(daLoginDet ails)
daDataAdapter.U pdate(dsDataSet , "myTable")

I get error when i try to update it. The error is on the Update line where
it saids "The DataAdapter.Sel ectCommand property needs to be initialized".

So i guess i was doing something wrong when filling the data??
or what is the proper way to make a fill data function? as i have many
tables to load into the dataset.

Hope anyone can help?
many thanks.

Nov 21 '05 #4
Jon
I tried to add something like that in the function, but it said

"Value of type System.Data.Ole Db.OleDbCommand .' cannot be converted to
'System.Data.Ol eDb.OleDbComman dBuilder'

?
thanks
"Darrell Wesley" wrote:
Try something like this:

da.SelectComman d = cmd
da.Fill(dsDataS et, tbName)
"Jon" wrote:
Hi,

I have a function to fill the data into the dataset:

Private Sub LoadSystemDataD B(ByVal m_str As String, ByVal da As _
OleDbDataAdapte r, ByVal tbName As String)
Dim OleDbConn As New OleDbConnection (OLEDB_CONNECTI ON_1)
OleDbConn.Open( )
da = New OleDbDataAdapte r(m_str, OleDbConn)
Dim cmd As New OleDbCommandBui lder(da)
da.Fill(dsDataS et, tbName)
dsDataSet.CaseS ensitive = True
OleDbConn.Close ()
End Sub

However when i try to update the data using:
Dim autogen As New OleDbCommandBui lder(daLoginDet ails)
daDataAdapter.U pdate(dsDataSet , "myTable")

I get error when i try to update it. The error is on the Update line where
it saids "The DataAdapter.Sel ectCommand property needs to be initialized".

So i guess i was doing something wrong when filling the data??
or what is the proper way to make a fill data function? as i have many
tables to load into the dataset.

Hope anyone can help?
many thanks.

Nov 21 '05 #5
Jon
thanks Darell, i have added the line

da.SelectComman d = cmd

just before the fill method.
but it saids:

"Value of type System.Data.Ole Db.OleDbCommand .' cannot be converted to
'System.Data.Ol eDb.OleDbComman dBuilder' "

hence could not compile.
Do you know the problem?
or is it the wrong method i m filling my dataset or my function?

many thanks. i hope someone can help me please?
Nov 21 '05 #6
I read your post wrong the first time and thought that cmd was a Command
object.

But : I don't believe that you need to create the commandbuilder twice, once
will do. Make certain that the dataset is available to you when the update
method is called and make certain that the connection back to the underlying
database is open.
"Jon" wrote:
thanks Darell, i have added the line

da.SelectComman d = cmd

just before the fill method.
but it saids:

"Value of type System.Data.Ole Db.OleDbCommand .' cannot be converted to
'System.Data.Ol eDb.OleDbComman dBuilder' "

hence could not compile.
Do you know the problem?
or is it the wrong method i m filling my dataset or my function?

many thanks. i hope someone can help me please?

Nov 21 '05 #7
Private Sub LoadSystemDataD B(ByVal m_str As String, ByRef da As _
OleDbDataAdapte r, ByVal tbName As String, ByRef cmd as OleDbCommandBui lder)
Dim OleDbConn As New OleDbConnection (OLEDB_CONNECTI ON_1)
da = New OleDbDataAdapte r
da.SelectComman d = new OleDBCommand(m_ str, OleDbConn)
Dim cmd As New OleDbCommandBui lder(da)
OleDbConn.Open
da.Fill(dsDataS et, tbName)
dsDataSet.CaseS ensitive = True
OleDbConn.Close ()
End Sub

Note the "ByRef" in the sub statement, these are Reference objects not value
objects.

"Jon" wrote:
Hi,

I have a function to fill the data into the dataset:

Private Sub LoadSystemDataD B(ByVal m_str As String, ByVal da As _
OleDbDataAdapte r, ByVal tbName As String)
Dim OleDbConn As New OleDbConnection (OLEDB_CONNECTI ON_1)
OleDbConn.Open( )
da = New OleDbDataAdapte r(m_str, OleDbConn)
Dim cmd As New OleDbCommandBui lder(da)
da.Fill(dsDataS et, tbName)
dsDataSet.CaseS ensitive = True
OleDbConn.Close ()
End Sub

However when i try to update the data using:
Dim autogen As New OleDbCommandBui lder(daLoginDet ails)
daDataAdapter.U pdate(dsDataSet , "myTable")

I get error when i try to update it. The error is on the Update line where
it saids "The DataAdapter.Sel ectCommand property needs to be initialized".

So i guess i was doing something wrong when filling the data??
or what is the proper way to make a fill data function? as i have many
tables to load into the dataset.

Hope anyone can help?
many thanks.

Nov 21 '05 #8
Jon
ic, Thank you very much!

"Darrell Wesley" wrote:
Private Sub LoadSystemDataD B(ByVal m_str As String, ByRef da As _
OleDbDataAdapte r, ByVal tbName As String, ByRef cmd as OleDbCommandBui lder)
Dim OleDbConn As New OleDbConnection (OLEDB_CONNECTI ON_1)
da = New OleDbDataAdapte r
da.SelectComman d = new OleDBCommand(m_ str, OleDbConn)
Dim cmd As New OleDbCommandBui lder(da)
OleDbConn.Open
da.Fill(dsDataS et, tbName)
dsDataSet.CaseS ensitive = True
OleDbConn.Close ()
End Sub

Note the "ByRef" in the sub statement, these are Reference objects not value
objects.

"Jon" wrote:
Hi,

I have a function to fill the data into the dataset:

Private Sub LoadSystemDataD B(ByVal m_str As String, ByVal da As _
OleDbDataAdapte r, ByVal tbName As String)
Dim OleDbConn As New OleDbConnection (OLEDB_CONNECTI ON_1)
OleDbConn.Open( )
da = New OleDbDataAdapte r(m_str, OleDbConn)
Dim cmd As New OleDbCommandBui lder(da)
da.Fill(dsDataS et, tbName)
dsDataSet.CaseS ensitive = True
OleDbConn.Close ()
End Sub

However when i try to update the data using:
Dim autogen As New OleDbCommandBui lder(daLoginDet ails)
daDataAdapter.U pdate(dsDataSet , "myTable")

I get error when i try to update it. The error is on the Update line where
it saids "The DataAdapter.Sel ectCommand property needs to be initialized".

So i guess i was doing something wrong when filling the data??
or what is the proper way to make a fill data function? as i have many
tables to load into the dataset.

Hope anyone can help?
many thanks.

Nov 21 '05 #9
Change Dim cmd As New OleDbCommandBui lder(da)
to cmd = new OleDbCommandBui lder(da)

The calling program should have the statements:

dim cb as OleDbCommandBui lder ' no NEW key word
Dim daDataAdapter as OleDbDataAdapte r ' no NEW keyword
Public dsDataSet as New DataSet ' needs to go in front of this module so
that it's truely public

Call LoadSystemDataD B(sqlString, daDataAdapter, TblName, cb)
' after the call returns back to the caller
Dim OleDbConn As New OleDbConnection (OLEDB_CONNECTI ON_1)
daDataAdapter.U pdate(dsDataSet , "myTable")
OleDbConn.Close

The subroutine will create the NEW version of it.
Don't create another NEW version in the calling program you only want it
once.

I also assume that the dataset is a Public Object that was created in the
calling program.
"Jon" <Jo*@discussion s.microsoft.com > wrote in message
news:43******** *************** ***********@mic rosoft.com...
ic, Thank you very much!

"Darrell Wesley" wrote:
Private Sub LoadSystemDataD B(ByVal m_str As String, ByRef da As _
OleDbDataAdapte r, ByVal tbName As String, ByRef cmd as
OleDbCommandBui lder)
Dim OleDbConn As New OleDbConnection (OLEDB_CONNECTI ON_1)
da = New OleDbDataAdapte r
da.SelectComman d = new OleDBCommand(m_ str, OleDbConn)
Dim cmd As New OleDbCommandBui lder(da)
OleDbConn.Open
da.Fill(dsDataS et, tbName)
dsDataSet.CaseS ensitive = True
OleDbConn.Close ()
End Sub

Note the "ByRef" in the sub statement, these are Reference objects not
value
objects.

"Jon" wrote:
> Hi,
>
> I have a function to fill the data into the dataset:
>
> Private Sub LoadSystemDataD B(ByVal m_str As String, ByVal da As _
> OleDbDataAdapte r, ByVal tbName As String)
> Dim OleDbConn As New OleDbConnection (OLEDB_CONNECTI ON_1)
> OleDbConn.Open( )
> da = New OleDbDataAdapte r(m_str, OleDbConn)
> Dim cmd As New OleDbCommandBui lder(da)
> da.Fill(dsDataS et, tbName)
> dsDataSet.CaseS ensitive = True
> OleDbConn.Close ()
> End Sub
>
> However when i try to update the data using:
> Dim autogen As New OleDbCommandBui lder(daLoginDet ails)
> daDataAdapter.U pdate(dsDataSet , "myTable")
>
> I get error when i try to update it. The error is on the Update line
> where
> it saids "The DataAdapter.Sel ectCommand property needs to be
> initialized".
>
> So i guess i was doing something wrong when filling the data??
> or what is the proper way to make a fill data function? as i have many
> tables to load into the dataset.
>
> Hope anyone can help?
> many thanks.
>
>

Nov 21 '05 #10

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

Similar topics

2
4217
by: hch | last post by:
dataAdapter.Update(data, "TableName") won’t work! I was about to deploy my first website on the Internet only to discover that the dataAdapter.Update() throws the Server Error in the third underline. It was working fine before. ConnectionString in Web.config: ----------------------------------------- <?xml version="1.0"...
1
1354
by: Galen Harris | last post by:
What's the best practice to use the dataadapter.update on a dataset that's been stored in session? We create a dataset on one page, and later in site, we want to call the dataadapter.update() to save the changes. Problem is, the original adapter is long gone. It seems like cloogy to recreate the exact adapter again, fill another dataset,...
1
2305
by: mivey4 | last post by:
Okay, The problem is that I have an Access Database that has the following fields: EmpID - Autonumber (PrimaryKey) AccountID - Text IssueReported - Memo DateOpened - Date/Time TimeOpened - Date/Time
2
2108
by: johnb41 | last post by:
I have a very simple application where i just want to display records from a database, and be able to edit the records. Here's the code for the "update" button: Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click DA.Update(DataSet, "mytable") End Sub
4
11153
by: George | last post by:
Got a question about the side effect of DataAdapter.Update() and DataTable.GetChanges(). Say I set up a DataTable and a DataAdapter in a class. Delete (Not remove) a row in the data table and call the following method. public void JobListDataTableFromAccessCommitChange() { System.Data.DataTable oChangeDataTable;
2
4562
by: Rich | last post by:
Hello, Is there a way to capture the Records Affected count when performing a table Update on a Sql Server table using a DataAdapter? How is this done? Thanks, Rich
5
2920
by: Emil | last post by:
I've created a very simple data base in Microsoft Access 2003. It consists of only one table called "Students" and it contains 2 information about each student: id-student and name. When I try to manipulate data in database I get an error, here's a sample: OleDbConnection connection; connection = new...
3
2341
by: Fred Chateau | last post by:
Any obvious reason here why data is not being loaded into the database? SqlDataAdapter dataAdapter = new SqlDataAdapter(sqlCommand); SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter); dataAdapter.Fill(dataSet, "POI_Entity"); DataRow dataRow = dataSet.Tables.NewRow(); dataRow = 1; dataRow =...
2
2886
by: BobLewiston | last post by:
I can read in an SQL table ("Person.Contact") from AdventureWorks and step through it one row at a time, but when I try to save a record, either one I'm inserting or one I'm editting, I get the following exception: Incorrect syntax near ','. Must declare scalar variable "@ContactID". Here's the code: private void btnSave_Click...
2
3869
by: BobLewiston | last post by:
Some of you may have seen my earlier thread “PasswordHash NULL problem”. I’ve started a new thread because investigation has shown that the problem is actually quite different than I previously stated. Also please note that this is unrelated to another of my previous threads, “dataAdapter.Update problem”, which incidentally has been resolved. ...
0
7568
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8007
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7526
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7852
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6109
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5409
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5133
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3537
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1990
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 we have to send another system

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.