dataset update

chrisb

Member
Joined
Oct 12, 2012
Messages
10
Programming Experience
Beginner
Hi
I was using dataset in my program in which i need to process and update changes back to database table. i have a problem in my dataset update code which is not updating change back to datatable. please help me in fixing up the code.
code
dt as datatable


{
datatable processing......
}
dt.AcceptChanges()
Me.ShopTableAdapter.Update(dt)
 
Don't call AcceptChanges. That means that the changes in the DataTable have been accepted, but they can't be accepted if they haven't been saved. Calling Update implicitly calls AcceptChanges after the changes have been saved, so there are only very specific situations where you need to call it explicitly.
 
dataset update -SQL Server in use does not support datatype 'date' error

thanks for your reply. now i have a error message in my program execution (The version of SQL Server in use does not support datatype 'date') . i haven't made any changes to date column in my dataset processing. how to deal with this issue?
 
The 'date' data type has been supported in T-SQL since SQL Server 2008. It sounds like you may have used some code that was written for SQL Server 2008 or later against a SQL Server 2005 or earlier database. If you want to support that earlier version then you'll have to adjust the database data types in your typed DataSet. Ideally you'd change the schema of your development database and use the wizard to regenerate the Data Source and typed DataSet.
 
This was given to us in a VB class. I'm going to post the whole thing here since it has been so handy for me.

Computer Information Science Programming 370 and 371

Table Adapter and Binding Source Commands

Version 1.0

NOTE:
Items shown in Bold Italic must be modified to match the names used in the program or the database table.

Add a Record
(This command will automatically clear all bound controls.)
BindingSourceName.AddNew()

Cancel an Add or Edit Process
BindingSourceName
.CancelEdit()
DatasetName.RejectChanges()

Delete a Record
BindingSourceName
.RemoveCurrent()
TableAdapterName.Update(DatasetName) for single table datasets
TableAdapterManagerName.UpdateAll(DatasetName) for multiple table datasets

Fill a Dataset
TableAdapterName
.Fill(DatasetName.TableName)

Fill a Dataset using a parameterized query
TableAdapterName
.Fill(DatasetName.TableName, "SearchValue")

Find and Display a Record
recordPosition
= BindingSourceName.Find("FieldName","SearchValue")
BindingSourceName.Position = recordPosition

Move One Record Backward
BindingSourceName
.MovePrevious()

Move One Record Forward
BindingSourceName
.MoveNext()

Move to a Specific Record
BindingSourceName
.Position = recordNumber

Move to the Beginning of the File
BindingSourceName
.MoveFirst()

Move to the End of the File
BindingSourceName
.MoveLast()

Record Count
recordCount
= BindingSourceName.Count()

Sort the Dataset
BindingSourceName
.Sort = "Field Name"

Update a Record After an Add or Edit Process has been started
BindingSourceName
.EndEdit()
TableAdapterName.Update(DatasetName) for single table datasets
TableAdapterManagerName.UpdateAll(DatasetName) for multiple table datasets

 
dataset valid UpdateCommand

thanks for your reply. i have deleted my dataset and created it to clear date error. now it shows error message Update requires a valid UpdateCommand when passed DataRow collection with modified rows @ Me.ShopTableAdapter.Update(dt) // (dt as dataset). please tell me how update my database table from modified dataset.
 
That suggests that your database table doesn't have a primary key. Without a primary key to uniquely identify a row, the system can't generate SQL code to update or delete a row.
 
dataset update resolved

That suggests that your database table doesn't have a primary key. Without a primary key to uniquely identify a row, the system can't generate SQL code to update or delete a row.

thanks for your reply. all good it working properly.
 
Back
Top