Showing posts with label string. Show all posts
Showing posts with label string. Show all posts

Friday, February 24, 2012

Error - updating tables row using SqlDataSource

I have such a problem:

i try to update a row in my table using:

protected void selectButton_Click(object sender, EventArgs e)
{
String taskID = projectsGridView.SelectedRow.Cells[0].Text;
usersSqlDataSource.UpdateCommand = "update [Users] set [TaskID]=@.task where [UserID]=1";
usersSqlDataSource.UpdateParameters.Add("task", taskID);
usersSqlDataSource.Update();
}

And i receive error on usersSqlDataSource.Update():

You have specified that your update command compares all values on SqlDataSource 'usersSqlDataSource', but the dictionary passed in for oldValues is empty

What have i done wrong? Parameter are not set?

Check ConflictDetection attribute in your DataSource declaration.

Based on your usage it should be

ConflictDetection="OverwriteChanges"

Refer to the following link to better understand the implications of this setting

http://msdn2.microsoft.com/en-US/library/system.web.ui.webcontrols.sqldatasource.conflictdetection.aspx

|||

One way to solve this is to change the ConflictDetection property of your datasource to OverWriteChanges. At the moment it is set at CompareAllValues. If you want to keep the CompareAllValues setting, you need to add the old Values for each parameter to the UpdateParameters collection too.http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.oldvaluesparameterformatstring(vs.80).aspx

|||

Yes, it works fine now, thanks!

Friday, February 17, 2012

error

what is max size for a string field in latest crystal report?. can it get increased?.I don't think there is any limitation in the crystal. But there is a limitation in UFL's or Function if there return type is string then they can only return maximum 256 character.

Does any body else has idea about this ?