I just can't seem to get the datagridview to update. I'm using 2005 vb.net
Here's my code for loading the grid (works fine) and my attempt at updating
via a save button...
Private SxAdapter As New OleDbDataAdapte r()
Private SxSource As New BindingSource()
Private SxTable As New DataTable()
Private Sub GetData(ByVal selectCommand As String)
Try
SQL = "Select LastName, FirstName, TestName, TestDate, Score
from TestScores"
SxAdapter = New OleDbDataAdapte r(selectCommand , CS)
Dim MyCommandBuilde r As New OleDbCommandBui lder(SxAdapter)
SxTable.Locale = System.Globaliz ation.CultureIn fo.InvariantCul ture
Me.SxAdapter.Fi ll(SxTable)
Me.SxSource.Dat aSource = SxTable
Catch ex As OleDbException
MessageBox.Show ("Error")
End Try
End Sub
in the form load...
Me.DataGridView 1.DataSource = Nothing
Me.DataGridView 1.Rows.Clear()
Me.DataGridView 1.DataSource = SxSource
GetData("Select LastName, FirstName, TestName, TestDate, Score from
TestScores")
and the save button...
Try
Me.Validate()
Me.SxSource.End Edit()
Dim myBuilder As OleDb.OleDbComm andBuilder = New
OleDb.OleDbComm andBuilder(Me.S xAdapter)
Me.SxAdapter.Up date(CType(Me.S xSource.DataSou rce, DataTable))
MsgBox("Update Successful")
Catch ex As Exception
MsgBox("Update Failed")
End Try
I'm stumpled... 4 5266
What does it do? Does it give you an error? Does it just act like
it did the update but it doesn't? In what way doesn't it work?
Robin S.
-------------------------------------------
"Arne Beruldsen" <Ar***********@ discussions.mic rosoft.comwrote in message
news:13******** *************** ***********@mic rosoft.com...
>I just can't seem to get the datagridview to update. I'm using 2005 vb.net
Here's my code for loading the grid (works fine) and my attempt at
updating
via a save button...
Private SxAdapter As New OleDbDataAdapte r()
Private SxSource As New BindingSource()
Private SxTable As New DataTable()
Private Sub GetData(ByVal selectCommand As String)
Try
SQL = "Select LastName, FirstName, TestName, TestDate, Score
from TestScores"
SxAdapter = New OleDbDataAdapte r(selectCommand , CS)
Dim MyCommandBuilde r As New OleDbCommandBui lder(SxAdapter)
SxTable.Locale =
System.Globaliz ation.CultureIn fo.InvariantCul ture
Me.SxAdapter.Fi ll(SxTable)
Me.SxSource.Dat aSource = SxTable
Catch ex As OleDbException
MessageBox.Show ("Error")
End Try
End Sub
in the form load...
Me.DataGridView 1.DataSource = Nothing
Me.DataGridView 1.Rows.Clear()
Me.DataGridView 1.DataSource = SxSource
GetData("Select LastName, FirstName, TestName, TestDate, Score from
TestScores")
and the save button...
Try
Me.Validate()
Me.SxSource.End Edit()
Dim myBuilder As OleDb.OleDbComm andBuilder = New
OleDb.OleDbComm andBuilder(Me.S xAdapter)
Me.SxAdapter.Up date(CType(Me.S xSource.DataSou rce, DataTable))
MsgBox("Update Successful")
Catch ex As Exception
MsgBox("Update Failed")
End Try
I'm stumpled...
Robin...
via the Catch...I simply get "Update Failed"
I'm confused...
"RobinS" wrote:
What does it do? Does it give you an error? Does it just act like
it did the update but it doesn't? In what way doesn't it work?
Robin S.
-------------------------------------------
"Arne Beruldsen" <Ar***********@ discussions.mic rosoft.comwrote in message
news:13******** *************** ***********@mic rosoft.com...
I just can't seem to get the datagridview to update. I'm using 2005 vb.net
Here's my code for loading the grid (works fine) and my attempt at
updating
via a save button...
Private SxAdapter As New OleDbDataAdapte r()
Private SxSource As New BindingSource()
Private SxTable As New DataTable()
Private Sub GetData(ByVal selectCommand As String)
Try
SQL = "Select LastName, FirstName, TestName, TestDate, Score
from TestScores"
SxAdapter = New OleDbDataAdapte r(selectCommand , CS)
Dim MyCommandBuilde r As New OleDbCommandBui lder(SxAdapter)
SxTable.Locale =
System.Globaliz ation.CultureIn fo.InvariantCul ture
Me.SxAdapter.Fi ll(SxTable)
Me.SxSource.Dat aSource = SxTable
Catch ex As OleDbException
MessageBox.Show ("Error")
End Try
End Sub
in the form load...
Me.DataGridView 1.DataSource = Nothing
Me.DataGridView 1.Rows.Clear()
Me.DataGridView 1.DataSource = SxSource
GetData("Select LastName, FirstName, TestName, TestDate, Score from
TestScores")
and the save button...
Try
Me.Validate()
Me.SxSource.End Edit()
Dim myBuilder As OleDb.OleDbComm andBuilder = New
OleDb.OleDbComm andBuilder(Me.S xAdapter)
Me.SxAdapter.Up date(CType(Me.S xSource.DataSou rce, DataTable))
MsgBox("Update Successful")
Catch ex As Exception
MsgBox("Update Failed")
End Try
I'm stumpled...
Robin...
The error reads
Dynamic SQL generation for the UpdateCommand is not supported against a
SelectCommand that does not return any key column information.
??
Arne
"RobinS" wrote:
What does it do? Does it give you an error? Does it just act like
it did the update but it doesn't? In what way doesn't it work?
Robin S.
-------------------------------------------
"Arne Beruldsen" <Ar***********@ discussions.mic rosoft.comwrote in message
news:13******** *************** ***********@mic rosoft.com...
I just can't seem to get the datagridview to update. I'm using 2005 vb.net
Here's my code for loading the grid (works fine) and my attempt at
updating
via a save button...
Private SxAdapter As New OleDbDataAdapte r()
Private SxSource As New BindingSource()
Private SxTable As New DataTable()
Private Sub GetData(ByVal selectCommand As String)
Try
SQL = "Select LastName, FirstName, TestName, TestDate, Score
from TestScores"
SxAdapter = New OleDbDataAdapte r(selectCommand , CS)
Dim MyCommandBuilde r As New OleDbCommandBui lder(SxAdapter)
SxTable.Locale =
System.Globaliz ation.CultureIn fo.InvariantCul ture
Me.SxAdapter.Fi ll(SxTable)
Me.SxSource.Dat aSource = SxTable
Catch ex As OleDbException
MessageBox.Show ("Error")
End Try
End Sub
in the form load...
Me.DataGridView 1.DataSource = Nothing
Me.DataGridView 1.Rows.Clear()
Me.DataGridView 1.DataSource = SxSource
GetData("Select LastName, FirstName, TestName, TestDate, Score from
TestScores")
and the save button...
Try
Me.Validate()
Me.SxSource.End Edit()
Dim myBuilder As OleDb.OleDbComm andBuilder = New
OleDb.OleDbComm andBuilder(Me.S xAdapter)
Me.SxAdapter.Up date(CType(Me.S xSource.DataSou rce, DataTable))
MsgBox("Update Successful")
Catch ex As Exception
MsgBox("Update Failed")
End Try
I'm stumpled...
Do you have a primary key defined in your table? And does your SELECT
statement include that field?
Robin S.
=============== ============
"Arne Beruldsen" <Ar***********@ discussions.mic rosoft.comwrote in message
news:0E******** *************** ***********@mic rosoft.com...
Robin...
The error reads
Dynamic SQL generation for the UpdateCommand is not supported against a
SelectCommand that does not return any key column information.
??
Arne
"RobinS" wrote:
>What does it do? Does it give you an error? Does it just act like it did the update but it doesn't? In what way doesn't it work?
Robin S. ------------------------------------------- "Arne Beruldsen" <Ar***********@ discussions.mic rosoft.comwrote in message news:13******* *************** ************@mi crosoft.com...
>I just can't seem to get the datagridview to update. I'm using 2005 vb.net
Here's my code for loading the grid (works fine) and my attempt at
updating
via a save button...
Private SxAdapter As New OleDbDataAdapte r()
Private SxSource As New BindingSource()
Private SxTable As New DataTable()
Private Sub GetData(ByVal selectCommand As String)
Try
SQL = "Select LastName, FirstName, TestName, TestDate, Score
from TestScores"
SxAdapter = New OleDbDataAdapte r(selectCommand , CS)
Dim MyCommandBuilde r As New OleDbCommandBui lder(SxAdapter)
SxTable.Locale =
System.Globaliz ation.CultureIn fo.InvariantCul ture
Me.SxAdapter.Fi ll(SxTable)
Me.SxSource.Dat aSource = SxTable
Catch ex As OleDbException
MessageBox.Show ("Error")
End Try
End Sub
in the form load...
Me.DataGridView 1.DataSource = Nothing
Me.DataGridView 1.Rows.Clear()
Me.DataGridView 1.DataSource = SxSource
GetData("Select LastName, FirstName, TestName, TestDate, Score from
TestScores")
and the save button...
Try
Me.Validate()
Me.SxSource.End Edit()
Dim myBuilder As OleDb.OleDbComm andBuilder = New
OleDb.OleDbComm andBuilder(Me.S xAdapter)
Me.SxAdapter.Up date(CType(Me.S xSource.DataSou rce,
DataTable))
MsgBox("Update Successful")
Catch ex As Exception
MsgBox("Update Failed")
End Try
I'm stumpled...
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: thomasp |
last post by:
I know this is a vague question, but I am not sure what information to give.
I am using VB2005 beta and the datagridview is pulling data from one of
three tables in an Access database. For some reason when I edit the feilds
that I have not set as readonly, the changes do not get written to the
database. I have the code that loads the datagridview posted below. Thanks
for any suggestions.
Thanks,
Thomas
|
by: Dave |
last post by:
I have a table with 3 fields of which the primary key is a autonumber. I have
created my dataadapter, dataset and datagridview using a wizard. However, in
the datagrid, the update and delete operation work but the Insert will not
work. I know I to make changes to code but it does not seem to work. portion
of the error reads:
The following exception occurred in the DataGridView:
System.Data.NoNullAllowedException: Column 'ID' does not...
|
by: Greg P |
last post by:
I am using VS2005 and have been learning a ton about databinding. I know
that when you drag a view from the datasource window (creating a
dataGridView) that an update method is not added to the table adaptor. I
would like to update the b ase tables thorugh the view. How do i do this?
FYI: I have some reserarch on how to handle updating multiple tables and
making sure I don't break referential integrity, yet in this case I will not
be...
|
by: joey.powell |
last post by:
I am using VS2005 for a windows forms application. I need to be able to
use a worker thread function to offload some processing from the UI
thread. The worker thread will need access to a datagridview on the
form. I am using the following code to spawn the worker thread...
Thread WorkerThread = new Thread(new ThreadStart(WT_MyFunction));
WorkerThread.IsBackground = true;
WorkerThread.Start();
The problem I am having is...I cannot seem...
|
by: Ivan |
last post by:
I have a class Foo which have two property. I have a thread that do
some process and update class Foo int B. I have a datagridview on main
form. this datagridview data source to this class Foo and column A
binds to string A and column B binds to int B. When i start two
threads, the datagridview able to show two rows and updated int B at
run time. How?
public class Foo
{
public Foo()
| |
by: =?Utf-8?B?THVib21pcg==?= |
last post by:
Hi,
I have a DataGridView that displays data from one table from database. I
didn’t implement any my code, I just used wizard to do all the work with
DatagridView populating.
Visual Studio generated strong typed dataset and binding. And here is my
problem.
I try to update the database with the new (changes) values from DataGridView:
|
by: sklett |
last post by:
I've got a strange situation here. I have a databound DataGridView that
also has un-bound columns. When the view loads, I want to update the values
of the unbound columns. If I attempt to modify the unbound column's cells
in the OnLoad() handler the results are very strange. If I add a button to
my view and update the unbound cells in the butt's handler it works fine.
Here is an example of the code I'm trying to use (it's test code):...
|
by: insirawali |
last post by:
Hi all,
I have this problem, i need to know is there a way i cn use the data
adapter's update method in this scenario.
i have 3 tables as below
create table table1{
id1 int identity(1,1)
Constraint pk_table1 Primary Key,
|
by: Oleg Subachev |
last post by:
I have DataGridView which DataSource is assigned to Table<>
object of DataContext connected to SQL Server database.
But when the underlying SQL Server database is updated
(through ODBC connection) the DataGridView is not updated.
I see that Table<is updated because its Count is changed.
How to force DataGridView to update itself in such situation ?
|
by: bharathi228 |
last post by:
Hi,
iam working with windows application.here my requirement is binding data to database from a datagridview.
next i want to update some rows in datagridview and update it to the database.for this purpose i need for each row loop in datagridview.i dont know how to update
the selected row in the datagridview.here my code in asp.net is like this.its working fine.but i want to do this in datagridview in windows application.
For...
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |