Hi,
I have a function to fill the data into the dataset:
Private Sub LoadSystemDataDB(ByVal m_str As String, ByVal da As _
OleDbDataAdapter, ByVal tbName As String)
Dim OleDbConn As New OleDbConnection(OLEDB_CONNECTION_1)
OleDbConn.Open()
da = New OleDbDataAdapter(m_str, OleDbConn)
Dim cmd As New OleDbCommandBuilder(da)
da.Fill(dsDataSet, tbName)
dsDataSet.CaseSensitive = True
OleDbConn.Close()
End Sub
However when i try to update the data using:
Dim autogen As New OleDbCommandBuilder(daLoginDetails)
daDataAdapter.Update(dsDataSet, "myTable")
I get error when i try to update it. The error is on the Update line where
it saids "The DataAdapter.SelectCommand 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. 9 8370
Try something like this:
da.SelectCommand = cmd
da.Fill(dsDataSet, tbName)
"Jon" wrote: Hi,
I have a function to fill the data into the dataset:
Private Sub LoadSystemDataDB(ByVal m_str As String, ByVal da As _ OleDbDataAdapter, ByVal tbName As String) Dim OleDbConn As New OleDbConnection(OLEDB_CONNECTION_1) OleDbConn.Open() da = New OleDbDataAdapter(m_str, OleDbConn) Dim cmd As New OleDbCommandBuilder(da) da.Fill(dsDataSet, tbName) dsDataSet.CaseSensitive = True OleDbConn.Close() End Sub
However when i try to update the data using: Dim autogen As New OleDbCommandBuilder(daLoginDetails) daDataAdapter.Update(dsDataSet, "myTable")
I get error when i try to update it. The error is on the Update line where it saids "The DataAdapter.SelectCommand 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.
Try placing a
da.SelectCommand = cmd
just prior to your fill statement.
"Jon" wrote: Hi,
I have a function to fill the data into the dataset:
Private Sub LoadSystemDataDB(ByVal m_str As String, ByVal da As _ OleDbDataAdapter, ByVal tbName As String) Dim OleDbConn As New OleDbConnection(OLEDB_CONNECTION_1) OleDbConn.Open() da = New OleDbDataAdapter(m_str, OleDbConn) Dim cmd As New OleDbCommandBuilder(da) da.Fill(dsDataSet, tbName) dsDataSet.CaseSensitive = True OleDbConn.Close() End Sub
However when i try to update the data using: Dim autogen As New OleDbCommandBuilder(daLoginDetails) daDataAdapter.Update(dsDataSet, "myTable")
I get error when i try to update it. The error is on the Update line where it saids "The DataAdapter.SelectCommand 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.
typo error:
Instead of
daDataAdapter.Update(dsDataSet, "myTable")
It should be:
daLoginDetails.Update(dsDataSet, "myTable")
can anyone help please?
"Jon" wrote: Hi,
I have a function to fill the data into the dataset:
Private Sub LoadSystemDataDB(ByVal m_str As String, ByVal da As _ OleDbDataAdapter, ByVal tbName As String) Dim OleDbConn As New OleDbConnection(OLEDB_CONNECTION_1) OleDbConn.Open() da = New OleDbDataAdapter(m_str, OleDbConn) Dim cmd As New OleDbCommandBuilder(da) da.Fill(dsDataSet, tbName) dsDataSet.CaseSensitive = True OleDbConn.Close() End Sub
However when i try to update the data using: Dim autogen As New OleDbCommandBuilder(daLoginDetails) daDataAdapter.Update(dsDataSet, "myTable")
I get error when i try to update it. The error is on the Update line where it saids "The DataAdapter.SelectCommand 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.
I tried to add something like that in the function, but it said
"Value of type System.Data.OleDb.OleDbCommand.' cannot be converted to
'System.Data.OleDb.OleDbCommandBuilder'
?
thanks
"Darrell Wesley" wrote: Try something like this:
da.SelectCommand = cmd da.Fill(dsDataSet, tbName)
"Jon" wrote:
Hi,
I have a function to fill the data into the dataset:
Private Sub LoadSystemDataDB(ByVal m_str As String, ByVal da As _ OleDbDataAdapter, ByVal tbName As String) Dim OleDbConn As New OleDbConnection(OLEDB_CONNECTION_1) OleDbConn.Open() da = New OleDbDataAdapter(m_str, OleDbConn) Dim cmd As New OleDbCommandBuilder(da) da.Fill(dsDataSet, tbName) dsDataSet.CaseSensitive = True OleDbConn.Close() End Sub
However when i try to update the data using: Dim autogen As New OleDbCommandBuilder(daLoginDetails) daDataAdapter.Update(dsDataSet, "myTable")
I get error when i try to update it. The error is on the Update line where it saids "The DataAdapter.SelectCommand 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.
thanks Darell, i have added the line
da.SelectCommand = cmd
just before the fill method.
but it saids:
"Value of type System.Data.OleDb.OleDbCommand.' cannot be converted to
'System.Data.OleDb.OleDbCommandBuilder' "
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?
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.SelectCommand = cmd
just before the fill method. but it saids:
"Value of type System.Data.OleDb.OleDbCommand.' cannot be converted to 'System.Data.OleDb.OleDbCommandBuilder' "
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?
Private Sub LoadSystemDataDB(ByVal m_str As String, ByRef da As _
OleDbDataAdapter, ByVal tbName As String, ByRef cmd as OleDbCommandBuilder)
Dim OleDbConn As New OleDbConnection(OLEDB_CONNECTION_1)
da = New OleDbDataAdapter
da.SelectCommand = new OleDBCommand(m_str, OleDbConn)
Dim cmd As New OleDbCommandBuilder(da)
OleDbConn.Open
da.Fill(dsDataSet, tbName)
dsDataSet.CaseSensitive = 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 LoadSystemDataDB(ByVal m_str As String, ByVal da As _ OleDbDataAdapter, ByVal tbName As String) Dim OleDbConn As New OleDbConnection(OLEDB_CONNECTION_1) OleDbConn.Open() da = New OleDbDataAdapter(m_str, OleDbConn) Dim cmd As New OleDbCommandBuilder(da) da.Fill(dsDataSet, tbName) dsDataSet.CaseSensitive = True OleDbConn.Close() End Sub
However when i try to update the data using: Dim autogen As New OleDbCommandBuilder(daLoginDetails) daDataAdapter.Update(dsDataSet, "myTable")
I get error when i try to update it. The error is on the Update line where it saids "The DataAdapter.SelectCommand 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.
ic, Thank you very much!
"Darrell Wesley" wrote: Private Sub LoadSystemDataDB(ByVal m_str As String, ByRef da As _ OleDbDataAdapter, ByVal tbName As String, ByRef cmd as OleDbCommandBuilder) Dim OleDbConn As New OleDbConnection(OLEDB_CONNECTION_1) da = New OleDbDataAdapter da.SelectCommand = new OleDBCommand(m_str, OleDbConn) Dim cmd As New OleDbCommandBuilder(da) OleDbConn.Open da.Fill(dsDataSet, tbName) dsDataSet.CaseSensitive = 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 LoadSystemDataDB(ByVal m_str As String, ByVal da As _ OleDbDataAdapter, ByVal tbName As String) Dim OleDbConn As New OleDbConnection(OLEDB_CONNECTION_1) OleDbConn.Open() da = New OleDbDataAdapter(m_str, OleDbConn) Dim cmd As New OleDbCommandBuilder(da) da.Fill(dsDataSet, tbName) dsDataSet.CaseSensitive = True OleDbConn.Close() End Sub
However when i try to update the data using: Dim autogen As New OleDbCommandBuilder(daLoginDetails) daDataAdapter.Update(dsDataSet, "myTable")
I get error when i try to update it. The error is on the Update line where it saids "The DataAdapter.SelectCommand 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.
Change Dim cmd As New OleDbCommandBuilder(da)
to cmd = new OleDbCommandBuilder(da)
The calling program should have the statements:
dim cb as OleDbCommandBuilder ' no NEW key word
Dim daDataAdapter as OleDbDataAdapter ' no NEW keyword
Public dsDataSet as New DataSet ' needs to go in front of this module so
that it's truely public
Call LoadSystemDataDB(sqlString, daDataAdapter, TblName, cb)
' after the call returns back to the caller
Dim OleDbConn As New OleDbConnection(OLEDB_CONNECTION_1)
daDataAdapter.Update(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*@discussions.microsoft.com> wrote in message
news:43**********************************@microsof t.com... ic, Thank you very much!
"Darrell Wesley" wrote:
Private Sub LoadSystemDataDB(ByVal m_str As String, ByRef da As _ OleDbDataAdapter, ByVal tbName As String, ByRef cmd as OleDbCommandBuilder) Dim OleDbConn As New OleDbConnection(OLEDB_CONNECTION_1) da = New OleDbDataAdapter da.SelectCommand = new OleDBCommand(m_str, OleDbConn) Dim cmd As New OleDbCommandBuilder(da) OleDbConn.Open da.Fill(dsDataSet, tbName) dsDataSet.CaseSensitive = 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 LoadSystemDataDB(ByVal m_str As String, ByVal da As _ > OleDbDataAdapter, ByVal tbName As String) > Dim OleDbConn As New OleDbConnection(OLEDB_CONNECTION_1) > OleDbConn.Open() > da = New OleDbDataAdapter(m_str, OleDbConn) > Dim cmd As New OleDbCommandBuilder(da) > da.Fill(dsDataSet, tbName) > dsDataSet.CaseSensitive = True > OleDbConn.Close() > End Sub > > However when i try to update the data using: > Dim autogen As New OleDbCommandBuilder(daLoginDetails) > daDataAdapter.Update(dsDataSet, "myTable") > > I get error when i try to update it. The error is on the Update line > where > it saids "The DataAdapter.SelectCommand 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. > > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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 ...
|
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...
|
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...
|
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
|
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...
|
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...
|
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...
|
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...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
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,...
|
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$) {
}
...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |