I have a bound datagrid on my windowsform. I have the following
declarations in the global module of the project:
Public eDS As DataSet
Public eDA As OleDb.OleDbDataAdapter
In the Load routine of the form, I have the following code
Dim eDS As New DataSet
Dim eDA As New OleDbDataAdapter
Dim e_strSQL As String
e_strSQL = "SELECT sysid, newDate, newTime , [desc] FROM event
WHERE con_id = '" & _
g_ContactID & "' ORDER BY newDate DESC"
eDA = New OleDbDataAdapter(e_strSQL, CN)
eDA.Fill(eDS, "Event")
Dim cb As New OleDbCommandBuilder(eDA)
DataGrid1.DataSource = eDS
DataGrid1.DataMember = eDS.Tables(0).TableName
This code works, and the table is filled.
When I try to update, using the following code, I get an error, "Object
reference not set to an instance of an object"
eDA.Update(eDS, "Event")
What am I missing?
Thanks,
Gary 7 2210
Gary:
Have you set the UpdateCommand property of your DataAdapter so it knows how
to update the datasource?
--
David Lloyd
MCSD .NET http://LemingtonConsulting.com
This response is supplied "as is" without any representations or warranties.
"Gary Paris" <te**@yada.com> wrote in message
news:uC**************@TK2MSFTNGP10.phx.gbl...
I have a bound datagrid on my windowsform. I have the following
declarations in the global module of the project:
Public eDS As DataSet
Public eDA As OleDb.OleDbDataAdapter
In the Load routine of the form, I have the following code
Dim eDS As New DataSet
Dim eDA As New OleDbDataAdapter
Dim e_strSQL As String
e_strSQL = "SELECT sysid, newDate, newTime , [desc] FROM event
WHERE con_id = '" & _
g_ContactID & "' ORDER BY newDate DESC"
eDA = New OleDbDataAdapter(e_strSQL, CN)
eDA.Fill(eDS, "Event")
Dim cb As New OleDbCommandBuilder(eDA)
DataGrid1.DataSource = eDS
DataGrid1.DataMember = eDS.Tables(0).TableName
This code works, and the table is filled.
When I try to update, using the following code, I get an error, "Object
reference not set to an instance of an object"
eDA.Update(eDS, "Event")
What am I missing?
Thanks,
Gary
Not sure how to set it or where to put it. Can you provide more details
please?
Thanks,
Gary
"David Lloyd" <Da***@NoSpamPlease.com> wrote in message
news:xI*****************@bignews4.bellsouth.net... Gary:
Have you set the UpdateCommand property of your DataAdapter so it knows how to update the datasource?
-- David Lloyd MCSD .NET http://LemingtonConsulting.com
This response is supplied "as is" without any representations or warranties.
"Gary Paris" <te**@yada.com> wrote in message news:uC**************@TK2MSFTNGP10.phx.gbl... I have a bound datagrid on my windowsform. I have the following declarations in the global module of the project:
Public eDS As DataSet Public eDA As OleDb.OleDbDataAdapter
In the Load routine of the form, I have the following code
Dim eDS As New DataSet Dim eDA As New OleDbDataAdapter Dim e_strSQL As String
e_strSQL = "SELECT sysid, newDate, newTime , [desc] FROM event WHERE con_id = '" & _ g_ContactID & "' ORDER BY newDate DESC"
eDA = New OleDbDataAdapter(e_strSQL, CN) eDA.Fill(eDS, "Event") Dim cb As New OleDbCommandBuilder(eDA)
DataGrid1.DataSource = eDS DataGrid1.DataMember = eDS.Tables(0).TableName This code works, and the table is filled. When I try to update, using the following code, I get an error, "Object reference not set to an instance of an object"
eDA.Update(eDS, "Event") What am I missing? Thanks, Gary
I thought the OleDbCommandBuilder creates the update code automatically? I
remember having a problem a few months ago and I was told to insert this
command. It worked and my data was updated. I took the roughly the same
code and tried again in a new project, but it isn't working. Maybe I'm
missing something.
HELP
"David Lloyd" <Da***@NoSpamPlease.com> wrote in message
news:xI*****************@bignews4.bellsouth.net... Gary:
Have you set the UpdateCommand property of your DataAdapter so it knows how to update the datasource?
-- David Lloyd MCSD .NET http://LemingtonConsulting.com
This response is supplied "as is" without any representations or warranties.
"Gary Paris" <te**@yada.com> wrote in message news:uC**************@TK2MSFTNGP10.phx.gbl... I have a bound datagrid on my windowsform. I have the following declarations in the global module of the project:
Public eDS As DataSet Public eDA As OleDb.OleDbDataAdapter
In the Load routine of the form, I have the following code
Dim eDS As New DataSet Dim eDA As New OleDbDataAdapter Dim e_strSQL As String
e_strSQL = "SELECT sysid, newDate, newTime , [desc] FROM event WHERE con_id = '" & _ g_ContactID & "' ORDER BY newDate DESC"
eDA = New OleDbDataAdapter(e_strSQL, CN) eDA.Fill(eDS, "Event") Dim cb As New OleDbCommandBuilder(eDA)
DataGrid1.DataSource = eDS DataGrid1.DataMember = eDS.Tables(0).TableName This code works, and the table is filled. When I try to update, using the following code, I get an error, "Object reference not set to an instance of an object"
eDA.Update(eDS, "Event") What am I missing? Thanks, Gary
Gary,
You have set the creation of a new referenced dataset in the load routine.
It still exist at update time, so you can get the dataset from the datagrid.
However you need that dataadapter with its builded commands as well, and
therefore I would keep it on. Dim eDS As New DataSet Dim eDA As New OleDbDataAdapter
eDS = BNew Dataset
eDa = New OleDbAdapter.
However in the way you do it has it not much sense you can do as well Public eDS As DataSet Public eDA As OleDb.OleDbDataAdapter
Public eDS as New Dataset
Public eDa as new OleDb.OleDbDataAdapter
I hope this helps,
Cor
Cor,
I made the changes you suggested and now I get an "Syntax error in UPDATE
statement"
I thought the update code was generated by the OLEDBCommandBuilder statement
that I put in the code. Did it not do it correctly?
Thanks,
Gary
"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... Gary,
You have set the creation of a new referenced dataset in the load routine.
It still exist at update time, so you can get the dataset from the datagrid.
However you need that dataadapter with its builded commands as well, and therefore I would keep it on.
Dim eDS As New DataSet Dim eDA As New OleDbDataAdapter eDS = BNew Dataset eDa = New OleDbAdapter.
However in the way you do it has it not much sense you can do as well Public eDS As DataSet Public eDA As OleDb.OleDbDataAdapter Public eDS as New Dataset Public eDa as new OleDb.OleDbDataAdapter
I hope this helps,
Cor
Gary,
Can you try to use the table names in your program in the same case as it is
in the Select statement, sometimes is that the trouble. As well is it often
the trouble that there is a reserved SQL word is used.
I hope this give some help
Cor
Cor,
Finally figured out what it is. I did look at the names and they are the
same. So I then looked at the field names in the select statement. One
field was [desc], so i renamed it desc1 and removed the brackets. Problem
solved.
Thanks for your suggestion.
Gary
"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl... Gary,
Can you try to use the table names in your program in the same case as it is in the Select statement, sometimes is that the trouble. As well is it often the trouble that there is a reserved SQL word is used.
I hope this give some help
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: sandman |
last post by:
I've got a simple windows form with some bound textboxes
and Save button. Each texbox is bound to column in a table
in an Access database. The form fills fine - all the
fields show the correct...
|
by: junglist |
last post by:
Hi guys,
I've been trying to implement an editable datagrid and i have been
succesful up to the point where i can update my datagrid row by row.
However what used to happen was that once i updated...
|
by: cwbp17 |
last post by:
I'm having trouble updating individual datagrid cells.
Have two tables car_master (columns include Car_ID, YEAR,VEHICLE) and
car_detail (columns include Car_ID,PRICE,MILEAGE,and BODY);both tables...
|
by: scorpion53061 |
last post by:
Well as some of you know I was using a tab control for a project I was
building for my boss.
Today he tells me that he wants:
When he switches tabs to be able to switch back and see whatever...
|
by: Geraldine Hobley |
last post by:
hello,
I have put thisup b4, but I think that people have misunderstood the problem, so I will make it clearer.
I have a problem updating a dataset that is bound to a datagrid.
The code that I...
|
by: jaYPee |
last post by:
does anyone experienced slowness when updating a dataset using
AcceptChanges?
when calling this code it takes many seconds to update the database
SqlDataAdapter1.Update(DsStudentCourse1)...
|
by: Lars Netzel |
last post by:
A little background:
I use three Datagrids that are in a child parent relation.
I Use Negative Autoincrement on the the DataTables and that's workning nice.
My problem is when I Update these...
|
by: susan.f.barrett |
last post by:
Hi,
Despite me being able to type the following in to SQL Server and it
updating 1 row:
> updatestockcategory 1093, 839
In my code, it is not updating any rows.
dataSet = new DataSet();
|
by: marcmc |
last post by:
Hey, I have never used a datagrid/dataset/adaptor/table method for updating
data, I have always used direct updates to the database so ADO is quite new
to me.
I have a datagrid and I change a...
|
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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: 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...
|
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...
|
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...
| |